How to show dropdown list in Xamarin Forms?

I am new to C# Xamarin.Forms and i would like to know how can i create dropdown list in Xamarin.Forms like we do in HTML using

<select id="TestDDL">

So how to achieve it?

Asked by:- pika
: 15951 At:- 2/22/2018 1:14:11 PM
C# Xamarin Forms Dropdown list in Xamarin

1 Answers
profileImage Answered by:- manish

Try using Picker in Xamarin.Form, which is similar to HTML dropdown list, here is example code snippet using Xaml

<Picker x:Name="picker" Title="Select a color">
    <x:Array Type="{x:Type x:String}">

in C#

var colorList= new List<string>();

var picker = new Picker { Title = "Select a color" };
picker.ItemsSource = colorList;

You can also call C# code, when value of picker changes using  SelectedIndexChanged event by binding to funtion, it will fire the method like below:

void OnPickerSelectedIndexChanged(object sender, EventArgs e)
  var picker = (Picker)sender;
  int selectedIndex = picker.SelectedIndex;

  if (selectedIndex != -1)
    //do somthing here

For reference you use

At:- 2/22/2018 3:44:40 PM
thanks that's what i was looking for :) 0
By : pika - at :- 2/23/2018 7:06:54 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use