Piya
Piya

Reputation: 93

How to create drop down list in windows phone

I am developing windows phone app. I want to create drop down list for names of states in India. How to create drop down list in windows phone ?

Upvotes: 2

Views: 6397

Answers (1)

Nagaraj S
Nagaraj S

Reputation: 13484

Source click

ListPicker control in the Windows Phone Toolkit, which provides many additional controls and pieces of functionality for Windows Phone development. It's not native to Visual Studio, but it's easy to install and use in apps. For a detailed tutorial on how to install it, I recommend you read this post

The ListPicker control has two modes of display: expansion mode and full-screen mode. By default, if there are five or fewer items in the ListPicker, the data will display in expansion mode, which most resembles a dropdown. If there are more than five items, the data will display in its own screen.

The XAML for adding a ListPicker is quite simple. If you want to hard-code your values in the ListPicker (and you have fewer than six items), your code will look something like this: enter image description here

This works great if your options aren't likely to change. However, if you need to programmatically add values to the ListPicker, you'll add this code to your MainPage.xaml.cs file: enter image description here

Alternatively, if the ListPicker values will be populated from a datasource, you have this option: enter image description here

In all of these examples, since the number of items is fewer than six, the ListPicker will expand in place:enter image description here

Upvotes: 5

Related Questions