Skip to content

Picker ItemDisplayBinding doesn't work with compiled bindings #23989

@davidortinau

Description

@davidortinau

Description

When I use ItemDisplayBinding in 8.0.80 nightly or .NET 9 Preview 7, the picker doesn't populate as I'd expect.

Screenshot 2024-08-02 at 2 32 52 PM

I can get around it using a ToString override on the model, or by providing the x:DataType=models:VocabularyList.

The ContentPage does specify a x:DataType for the view model. This doesn't work:

<Picker x:Name="VocabPicker" 
    ItemsSource="{Binding VocabLists}"
    ItemDisplayBinding="{Binding Name}"                    
    SelectedItem="{Binding VocabList, Mode=TwoWay}" />

This does work:

<Picker x:Name="VocabPicker" 
    ItemsSource="{Binding VocabLists}"
    ItemDisplayBinding="{Binding Name, x:DataType=models:VocabularyList}"                    
    SelectedItem="{Binding VocabList, Mode=TwoWay}" />
Screenshot 2024-08-02 at 2 53 10 PM

Steps to Reproduce

https://github.com/davidortinau/SentenceStudio/blob/main/src/SentenceStudio/Pages/Lesson/LessonStartPage.xaml

My testing with the original code:

8.0.71 - Debug - Good
8.0.71 - Release - Good
8.0.80 - Debug - Sad
8.0.80 - Release - Good

Link to public reproduction project repository

No response

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.61 SR6.1

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

No response

Did you find any workaround?

Yes, as described

Relevant log output

No response

Metadata

Metadata

Labels

area-xamlXAML, CSS, Triggers, Behaviorsfixed-in-9.0.0-rc.2.24503.2i/regressionThis issue described a confirmed regression on a currently supported versionp/0Current heighest priority issues that we are targeting for a release.platform/androidplatform/iosplatform/macosmacOS / Mac Catalystplatform/windowspotential-regressionThis issue described a possible regression on a currently supported version., verification pendingt/bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions