How to display two items a string and an Image in Xamarin Picker control?

3.1k views Asked by At

I have a situation where I need to display a picker control in Xamarin like the following way.enter image description here

Where it will display the country Flag and Country code side by side. And the selected country code should display as the background image of the Picker control. (As in the image)

I have just started with Xamarin and found that Picker doesn't have ItemSource property like WPF XAML and it doesn't support DataTemplate too.

Using a listView I can achieve this but ListView Control and Picker controls usability are different.

Can anybody guide me how can I achieve this feature in Picker in Xamarin-XAML?

2

There are 2 answers

3
Muhammad Azeez On

Picker.Items is an IList<string> so I think you can't do that, because it's made to hold strings only. See: https://developer.xamarin.com/api/property/Xamarin.Forms.Picker.Items/

However you can make another page and on that page place a ListView so that the use can set the language there.

0
littlegreendude On

A ListView with an ImageCell within the DataTemplate.

Check out Chapter 19, around page 587 of Charles Petzold's eBook. You can download it from here:

Creating Mobile Apps with Xamarin.Forms Book First Edition