Trying to get a Windows Phone 8 ListPicker to work
c#, silverlight, windows-phone, windows-phone-8, xaml
Solution
The code behind is fine. This is a xaml issue. Try this approach instead in your xaml file.
1) Define your data templates as PhoneApplicationPage Resources which bind to the moduleNumber array from the code behind.
2) Then bind your list picker to the templates.
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Name="modulePickerItemTemplate">
<StackPanel>
<TextBlock Text="{Binding moduleNumber}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="modulePickerFullItemTemplate">
<StackPanel>
<TextBlock Text="{Binding moduleNumber}"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<toolkit:ListPicker ExpansionMode="FullScreenOnly" FullModeHeader="Select Module"
Name="modulePicker"
FullModeItemTemplate="{Binding modulePickerFullItemTemplate}"
ItemTemplate="{Binding modulePickerItemTemplate}" />
Problem
The ListPicker functions, in that I can click on it and a full screen popup appears, but there are options to choose from. My xaml: ``` <toolkit:ListPicker ExpansionMode="FullScreenOnly" FullModeHeader="Select Module" Name="modulePicker"> <toolkit:ListPicker.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding moduleNumber}"/> </StackPanel> </DataTemplate> </toolkit:ListPicker.ItemTemplate> <toolkit:ListPicker.FullModeItemTemplate> <DataTemplate> <StackPanel"> <TextBlock Text="{Binding moduleNumber}"/> </StackPanel> </DataTemplate> </toolkit:ListPicker.FullModeItemTemplate> </toolkit:ListPicker> ``` And the C# behind it includes: ``` String[] moduleNumber = { "AA1", "AA2", "AA3" }; ``` and ``` public MainPage() { InitializeComponent(); this.modulePicker.ItemsSource = moduleNumber; } ``` So what do I need to do to get the strings listed in moduleNumber to display on the ListPicker? If you need to know more just ask.