我一直使用以下代码在Dispatcher中绑定wpf ListBox
Dispatcher.BeginInvoke(new Action(() =>
{
LoadData();
}));
private void LoadData()
{
// Written some logic here
}它很好地绑定了ListBox,但当我调用
ListBoxItem myListBoxItem = (ListBoxItem)(routeList.ItemContainerGenerator.ContainerFromItem(item));它总是返回给我null.Problem只有当我在Dispatcher中绑定ListBox时才会发生。如果我在类构造函数中绑定相同的ListBox,它会工作得很好。
https://stackoverflow.com/questions/38200454
复制相似问题