我在我的xaml代码中有一个ListPicker,它包含的不止是ListPickerItem,我想根据选择的ListPickerItem在我的地图上显示一个图钉。如何在windows phone 8中基于ListPickerItem选择做功能
这是我的XAML:
<toolkit:ListPicker Foreground="white" Opacity="0.9" x:Name="OptionSelection" Margin="0,18,0,0" SelectionChanged="Picker">
<toolkit:ListPickerItem Tag="1" x:Name="Option1" Content="Item1"/>
<toolkit:ListPickerItem Tag="2" x:Name="Option2" Content="Item2"/>
<toolkit:ListPickerItem Tag="3" x:Name="Option3" Content="Item3"/>
</toolkit:ListPicker>
这里是SelectionChanged事件我的CS代码:
private void Picker(object sender, SelectionChangedEventArgs e)
{
var tag = ((ListPickerItem)OptionSelection.SelectedItem).Tag;
if (tag.Equals(1))
{
MessageBox.Show("Item1 selected"); //I will replace this with my geolocation function later.
}
}
主要是我想知道的if语句如何应用在我的代码,这将有助于我根据选定的项目添加地理定位功能。
什么问题吗? – Sajeetharan
它给出了一个例外,这里详细说明 DataBoundApp3.DLL中发生了类型'System.NullReferenceException'的异常,但未在用户代码中处理 附加信息:未将对象引用设置为对象的实例。 – user3269487