When I bind my data via item source to my ListPicker
:
C#:
var sightingTypes = SightingTypes.List;
sightingTypesPicker.ItemsSource = sightingTypes;
XML:
<toolkit:ListPicker x:Name="sightingTypesPicker" ItemsSource="{Binding sightingTypes, ElementName=this}">
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontSize="{StaticResource PhoneFontSizeSmall}"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
</toolkit:ListPicker>
I can see the Name being shown in the ListPicker, but, when I click on the ListPicker it shows the List of the Object Type, like this:
MyProject.Model.SightingType
MyProject.Model.SightingType
MyProject.Model.SightingType
MyProject.Model.SightingType
MyProject.Model.SightingType
MyProject.Model.SightingType
How do I:
A: Make the Name
Property show when the list shows
B: Bind the ID
Property as the Value but not show it
You need to assign
FullModeItemTemplate
for that to work:EDIT: To answer your question B: You can use the SelectedItem DependencyProperty to get the instance of the selected object:
With MVVM approach:
With code-behind approach: