我使用以下代码创建了带有windows phone工具包的listpicker:
<toolkit:ListPicker ExpansionMode="FullScreenOnly" x:Name="myLst" Header="Pilih Peta :" BorderThickness="2" BorderBrush="Black" SelectedIndex="-1" Grid.Row="2">
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Margin="0 24 24 24" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle2Style}" />
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>
然后我在xaml.cs中添加数据:
List<string> _tipe = new List<string>();
_tipe.Add("one");
_tipe.Add("two");
_tipe.Add("three");
myLst.ItemsSource = _tipe;
我想要做的是在我的List Picker中的selectionChanged时显示MessageBox。怎么样?
谢谢之前:)
答案 0 :(得分:0)
在XAML中附加事件处理程序:
<toolkit:ListPicker SelectionChanged="ListPicker_SelectionChanged"
.......
>
.......
</toolkit:ListPicker>
使事件处理程序显示消息框:
private void ListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (myLst.SelectedItem != null)
MessageBox.Show(myLst.SelectedItem.ToString());
}