the_tr00per
the_tr00per

Reputation: 439

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

Upvotes: 0

Views: 470

Answers (1)

Jason
Jason

Reputation: 89117

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}"

Upvotes: 3

Related Questions