How to display a property or member of a custom object in Xamarin.Forms Picker?
The Xamarin.Forms Picker provides a support to display a particular object in picker. This can be achieved by setting a particular property to the DisplayMemeberPath property.
The following steps demonstrates how to display a particular object in Xamarin.Forms SfPicker.
Step 1: Create a model class and declare properties to display the items in Xamarin.Forms SfPicker.
Step 2: Create a view model class and create symbol ObservableCollection with model class type.
Step 3: Set value to the model class properties and add the properties to that collection.
Step 4: Set the model class property to DisplayMemberPath to display the particular items in Xamarin.Forms SfPicker.
XAML:
<picker:SfPicker HeaderText="Select a person" ShowHeader="true" ItemsSource="{Binding People}" DisplayMemberPath="LastName"> </picker:SfPicker>
You can find the sample in the following link: Sample
Screenshot:
Conclusion
I hope you enjoyed learning about how to display a property or member of a custom object in Xamarin.Forms Picker.
You can refer to our Xamarin.Forms Picker feature tour page to know about its other groundbreaking feature representations. You can also explore our Xamarin.Forms Picker documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!