Skip to content

fix: LabeledPicker.ItemDisplayBinding not applied — plain CLR property again - #38

Merged
nord- merged 2 commits into
masterfrom
fix/labeledpicker-itemdisplaybinding
Jul 3, 2026
Merged

nord- merged 2 commits into
masterfrom
fix/labeledpicker-itemdisplaybinding

Conversation

@nord-

@nord- nord- commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Fixes #37.

Root cause

ItemDisplayBinding was converted to a BindableProperty in 3eb2653 (closing #5). When the target is a BindableProperty, XamlC compiles ItemDisplayBinding="{Binding DisplayName}" into SetBinding — the binding gets applied against the LabeledPicker's BindingContext (the page view model) instead of being assigned as a value. The path never resolves, the inner Picker.ItemDisplayBinding stays null, and rows fall back to ToString() — hence the fully-qualified type names.

This is why MAUI's own Picker.ItemDisplayBinding is 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 type BindingBase — 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 Element is assigned in InitializeComponent before any consumer property set):

public BindingBase ItemDisplayBinding
{
    get => Element.ItemDisplayBinding;
    set => Element.ItemDisplayBinding = value;
}

Verified: library and demo app build clean; the demo's MainPage.xaml exercises the consumer-side ItemDisplayBinding="{Binding ...}" path through XamlC.

https://claude.ai/code/session_01WitcHAJWfFmjKdSHWXgHRv

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
Copilot AI review requested due to automatic review settings July 3, 2026 08:27
@nord- nord- added the patch label Jul 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ItemDisplayBinding BindableProperty and related property-changed plumbing.
  • Added a plain CLR ItemDisplayBinding property that forwards to Element.ItemDisplayBinding, with an explanatory comment referencing #37.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread NiceEntry/LabeledPicker.xaml.cs Resolved
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
@nord-
nord- merged commit 2ad8233 into master Jul 3, 2026
1 check passed
@nord-
nord- deleted the fix/labeledpicker-itemdisplaybinding branch July 3, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: LabeledPicker.ItemDisplayBinding not applied — shows item's type name instead

2 participants