Repository navigation
fix: LabeledPicker.ItemDisplayBinding not applied — plain CLR property again - #38
Merged
Merged
Conversation
As a BindableProperty, XamlC compiles ItemDisplayBinding="{Binding X}" in
consumer XAML into SetBinding against the page's BindingContext instead of
assigning the binding object itself. The path never resolves on the view
model, the inner Picker's ItemDisplayBinding stays null, and rows fall back
to ToString() (the item's type name).
MAUI's own Picker.ItemDisplayBinding is deliberately a plain CLR property
for exactly this reason. This reverts the regression introduced in 3eb2653
(which closed #5) and restores the approach from 165630c.
Claude-Session: https://claude.ai/code/session_01WitcHAJWfFmjKdSHWXgHRv
There was a problem hiding this comment.
Pull request overview
This PR fixes LabeledPicker.ItemDisplayBinding not being applied by reverting it from a BindableProperty back to a plain CLR property that forwards directly to the inner Picker, aligning with MAUI’s Picker.ItemDisplayBinding behavior and restoring correct XAML assignment semantics.
Changes:
- Removed the
ItemDisplayBindingBindablePropertyand related property-changed plumbing. - Added a plain CLR
ItemDisplayBindingproperty that forwards toElement.ItemDisplayBinding, with an explanatory comment referencing #37.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The inner Picker's ItemDisplayBinding is null until set, so the forwarding getter can return null. Annotate the property as BindingBase? so the API surface matches reality for NRT-enabled consumers. Claude-Session: https://claude.ai/code/session_01WitcHAJWfFmjKdSHWXgHRv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #37.
Root cause
ItemDisplayBindingwas converted to aBindablePropertyin 3eb2653 (closing #5). When the target is a BindableProperty, XamlC compilesItemDisplayBinding="{Binding DisplayName}"intoSetBinding— the binding gets applied against theLabeledPicker'sBindingContext(the page view model) instead of being assigned as a value. The path never resolves, the innerPicker.ItemDisplayBindingstaysnull, and rows fall back toToString()— hence the fully-qualified type names.This is why MAUI's own
Picker.ItemDisplayBindingis deliberately a plain CLR property, and why 165630c originally made it one here. #5 was based on a misunderstanding: the inline binding syntax doesn't "happen to work" on a CLR property of typeBindingBase— it's the intended XAML behavior, and a BindableProperty is what breaks it.Fix
Revert to a plain CLR property forwarding directly to the inner picker (the getter no longer needs null-forgiveness since
Elementis assigned inInitializeComponentbefore any consumer property set):Verified: library and demo app build clean; the demo's
MainPage.xamlexercises the consumer-sideItemDisplayBinding="{Binding ...}"path through XamlC.https://claude.ai/code/session_01WitcHAJWfFmjKdSHWXgHRv