In our Xamarin Forms, SfPicker control has Multi column support based on collection. So we can add or remove the collection based on our requirements. Using this we can populate Country and States of the respective Country in a collection using SfPicker control.
We have demonstrated how to create custom Cascading sample using Picker control in the following steps.
We have created the cascading sample for updating state collection based on SelectedItem of SfPicker.
Please refer the below steps to create the cascading sample
Step 1: We have created three ObservableCollection with object type in PickerCascading class.
Area Collection, Country Collection and State Collection.
Country Collection -> We have added country names.
State Collection -> We have added state names.
Area Collection -> We have added above 2 collections.
Area Collection is main collection we have assigned this collection to ItemsSource of Picker Control.
The below code demonstrates Area collection creation.
Step 2: We have updated the state collection based on selected item of country name using Selection changed event of SfPicker control.
Step 3: We have defined column headers as “Country” and “State” using ColumnHeaderText property of SfPicker control. The below code demonstrates how to define header for each column of SfPicker control.
Step 4: We have added the cascading picker control in main XAML page. Please refer the below code snippets.
Please find the below screen shot using the above codes.
We have attached Cascading sample for your reference. Please download the sample from the following link.
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|