Saturday, December 4, 2010

How to add items to Windows Phone 7 ListPicker

I figured  out how to add list items from code behind. For some one who might have a similar problem, my solution is given below.
I created an observable collection

Code behind

int startyear 2000;
int endyear 2010;
ObservableCollection<string> yearlist = new ObservableCollection<string>();
for (int i = endyear; i >= startyear; i--)
YearListPicker.ItemsSource = yearlist;


<toolkit:ListPicker  Margin="4,4,4,4" 
x:Name="YearListPicker" Header="Year" >

Interesting article on ListPicker

No comments:

Post a Comment