简体   繁体   中英

Xamarin Forms Picker - Databind a custom data type

I'm currently using a xamarin forms picker and the example fworks fine as it's a List. ( https://developer.xamarin.com/samples/xamarin-forms/UserInterface/BindablePicker/ )

I need to bind it to a custom type:

    StaffList= new ObservableRangeCollection<Staff>();

Problem is that the custom type Staff has multiple properties and types. for example: Id, name, age...

I only want the name to display in picker,

Is this possible, or is there only a list of strings that can attchieve this?

Thanks

The article you link to gives an example of doing EXACTLY what you want. Use ItemDisplayBinding to specify which property of your object you want displayed in the Picker.

ItemDisplayBinding="{Binding Name}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM