Search code examples
xamlwindows-phone-8keylistpickerwindows-phone-8-sdk

Add a key to ListPickerItem


XAML:

<toolkit:ListPicker x:Name="profession" SelectionChanged="ListPicker_SelectionChanged">
    <toolkit:ListPickerItem Content="Value1" />
</toolkit:ListPicker>

How can I add a key to the ListPickerItem to be used in the C# code?

What I want is similar to HTML's value attribute for the option control.

Example of what I want: (C# code, OFC not working..)

int a = profession.SelectedItem.Key;

Solution

  • You can use the Tag property.

    <toolkit:ListPickerItem Content="Value1" Tag="1"/>
    
    var a = ((ListPickerItem)profession.SelectedItem).Tag;