我在 WindowsPhone 应用程序中使用列表选择器,我无法在列表选择器中加载所选元素,所选值显示在页面加载期间加载的第一个项目,但我们在选择更改事件中获得的值是正确一个。请帮助我
XAML:
<Grid.Resources>
<DataTemplate x:Name="picker">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Margin="0 0 0 0" FontSize="25" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="PickerFullModeItemTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Margin="0 0 0 0" FontSize="18" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
</StackPanel>
</DataTemplate>
</Grid.Resources>
<toolkit:ListPicker ItemTemplate="{StaticResource PickerFullModeItemTemplate}" FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}" x:Name="list_city" Grid.Row="3" Grid.Column="5" Grid.ColumnSpan="2" VerticalAlignment="Top" SelectionChanged="list_city_SelectionChanged" Height="170" Grid.RowSpan="1" Margin="12,12,12,0" />
C# :
private void list_city_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = list_city.SelectedIndex;
string val = lst_cities[i]; //list of cities
}