How to use Picker as country Picker in .NET MAUI Picker (SfPicker)?
In the Syncfusion .NET MAUI Picker control, learn how to use Picker as Country Picker by following this demonstration.
XAML:
Initialize the SfPicker Control, and use HeaderView and FooterView properties of SfPicker to customize the picker.
<picker:sfpicker x:name="picker">
<picker:sfpicker.headerview>
<picker:pickerheaderview text="Select a Country" height="40">
</picker:pickerheaderview></picker:sfpicker.headerview>
<picker:sfpicker.footerview>
<picker:pickerfooterview height="40">
</picker:pickerfooterview></picker:sfpicker.footerview>
</picker:sfpicker>
C#:
Set the ItemSource property of the PickerColumn class as illustrated the following code to bind the item source in the picker.
ObservableCollection<object> countryName = new ObservableCollection<object>();
countryName.Add("UnitedStates");
countryName.Add("Qatar");
countryName.Add("India");
countryName.Add("Germany");
countryName.Add("Spain");
countryName.Add("Malaysia");
countryName.Add("Netherlands");
countryName.Add("Mexico");
countryName.Add("Brazil");
PickerColumn pickerColumn = new PickerColumn()
{
ItemsSource = countryName,
SelectedIndex = 3,
};
this.picker.Columns.Add(pickerColumn);
Output:
Conclusion:
I hope you enjoyed learning how to use Picker as Country Picker in the .NET MAUI Picker (SfPicker).
Refer to our .NET MAUI Picker feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Picker documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our .NET MAUI Picker and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!