ListPicker System.InvalidCastException访问绑定对象时

时间:2014-07-14 11:18:52

标签: c# windows-phone-8 listpicker

以下是代码XAML:                                                                                                                                                                              

这是C#:                 textDefault.Text ="所选项目是" +((Items)this.listPicker.SelectedItem).Name;

1 个答案:

答案 0 :(得分:0)

你应该把它投射到你绑定的类

这样的事,

ClassType =  (ClassType)listPicker.SelectedItem;
if(ClassType != null)
{
textDefault.Text = "Selected Item is " +ClassType.Name;
}