我用下面的代码创建了带有windows工具包的列表选择器:
<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;我想要做的是在我的列表选择器中显示MessageBox何时selectionChanged。怎么做到的?
(谢谢:)
发布于 2014-05-04 11:35:02
在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());
}https://stackoverflow.com/questions/23455649
复制相似问题