ObservableCollection<>
. 所以我的代码是这样的:
private ObservableCollection<MyItem> _items;
public ObservableCollection<MyItem> Items
{
get { return _items; }
set
{
if (_items.Equals(value))
{
return;
}
_items = value;
RaisePropertyChanged("Items");
}
}
private void LoadData()
{
Task task = Task.Factory.StartNew(() =>
{
ObservableCollection<MyItem> itms = _htmlParser.FetchData(...);
Dispatcher.CurrentDispatcher.Invoke((Action)delegate
{
Items = itms;
});
});
}
Must create DependencySource on same Thread as the DependencyObject.
我正在使用mvvmlighttoolkit框架。我还试图将结果作为一条消息发送,但结果是相同的错误消息。有什么想法或建议吗?
public class MyItem
{
public string Id { get; set; }
public string Name { get; set; }
public BitmapImage Image { get; set; } // <--- A big No No because it inherits from the DependencyObject
public Uri Uri { get; set; }
}
我换了衣服
BitmapImage
到
byte[]
数据类型。