Я предполагаю, что вы хотите связать со свойством типа enum, как это?
public enum EnumType { Item1, Item2 }
public EnumType Property { get; set; }
Вот как я это сделал:
(в конструкторе)
theListPicker.ItemsSource = Enum.GetValues(typeof(EnumType));
(XAML)
<phone:PhoneApplicationPage
...
x:Name="_this"/>
...
<phone:PhoneApplicationPage.Resources>
<local:EnumIntConverter x:Name="enumIntConverter"/>
</phone:PhoneApplicationPage.Resources>
....
<toolkit:ListPicker ...
SelectedIndex="{Binding ElementName=_this, Path=Property, Converter={StaticResource enumIntConverter}, Mode=TwoWay}
(где-то в вашем пространстве имен)
public class EnumIntConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (int)(EnumType)value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Enum.GetValues(typeof(EnumType)).GetValue((int)value);
}
}
В моем случае я также хотел использовать описания enum вместо их имен,поэтому я использую этот код вместо однострочного "в конструкторе" выше:
Array rawValues = Enum.GetValues(typeof(EnumType));
List<string> values = new List<string>();
foreach (EnumType e in rawValues)
values.Add((typeof(EnumType).GetMember(e.ToString())[0].GetCustomAttributes(typeof(DescriptionAttribute), false)[0] as DescriptionAttribute).Description);
theListPicker.ItemsSource = values;