WPF ListBox选中获取子分类时异常“未将对象引用设置到对象实例” 附代码 求指点
privatevoidsecondCate_SelectionChanged(objectsender,SelectionChangedEventArgse){try{l...
private void secondCate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
long cid = (this.secondCate.SelectedItem as ItemCat).Cid;
Cid = cid;
List<ItemCat> icList = gs.getItemcates(cid).ItemCats;
this.Dispatcher.Invoke(new ThreadActionHandler((obj) =>
{
List<ItemCat> iList = obj as List<ItemCat>;
if (iList.Count != 0)
{
this.secondCate.ItemsSource = iList;
}
else
{
WinMsgDialog.Show("该分类无子类目!", "提示");
this.secondCate.ItemsSource = null;
}
}), icList);
}
catch (Exception ex)
{
WinMsgDialog.Show("" + ex.Message, "异常");
} } 展开
{
try
{
long cid = (this.secondCate.SelectedItem as ItemCat).Cid;
Cid = cid;
List<ItemCat> icList = gs.getItemcates(cid).ItemCats;
this.Dispatcher.Invoke(new ThreadActionHandler((obj) =>
{
List<ItemCat> iList = obj as List<ItemCat>;
if (iList.Count != 0)
{
this.secondCate.ItemsSource = iList;
}
else
{
WinMsgDialog.Show("该分类无子类目!", "提示");
this.secondCate.ItemsSource = null;
}
}), icList);
}
catch (Exception ex)
{
WinMsgDialog.Show("" + ex.Message, "异常");
} } 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询