Must create DependencySource on same Thread as DependencyObject

后端 未结 3 1068
甜味超标
甜味超标 2021-01-04 14:10

I have an application written in wpf, which downloads some webpages, parses html code and saves some values.

class ListOfItems
{    
    public List

        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 14:39

    Its not enough to set your dataGrid.ItemsSource on the main thread. You must create each item on the main-thread. Something like:

    List l = new List();
    foreach(var item in ListOfItemsInstance.ListToBind)
    {
        l.Add(new SomeObject(){NameOfItem = item.NameOfItem, Properties = item.Properties });
    }
    
    dataGrid.ItemsSource = l;
    

提交回复
热议问题