WPF Threading: can I update the context of control data in a thread other than the UI?

Is it possible to update the data context of a WPF control in a thread other than the UI?

Let's say we have Labelone that has MyClassboth a data context and binds Contentto MyProperty:

<Label Name="label" Content="{Binding MyProperty}" />,

where is MyClasssimple:

public class MyClass : INotifyPropertyChanged
{
    int _myField;
    public int MyProperty
    {
        get
        {
            return _myField;
        }
        set
        {
            _myField = value;
            PropertyChanged(this, new PropertyChangedEventArgs("MyProperty"));
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
}

In a thread other than the UI, we can do myClass.MyProperty = "updated"to update the contents of the label, but we can not do label.Content = "updated"directly. It is right?

My own answer :

Here is what I found:

+5
1

, . ( CollectionChanged ).

ObservableCollection<T> . , UI, , , (ObservableCollection<T> , ). , ObservableCollection<T>, ( ).

+2

All Articles