I'm trying to access the header properties of a TreeView control in a background worker's DoWork method.
I have tried the following:
var worker = new BackgroundWorker();
worker.DoWork += DoWork;
worker.RunWorkerAsync(MyTreeView);
private void DoWork(object sender, DoWorkEventArgs e)
{
    var x = (e.Argument as TreeView);
    var item1 = x.Items[0] as TreeViewItem;
    //error here..
    var headerItem1 = item1.Header;
}
The error that is thrown says that the property I want to access is owned by another thread (the UI thread in my case).
I have had this problem only with the TreeView control so far. Passing and then accessing less 'complex' controls like Labels or TextBlocks has worked fine.
Thanks for every answer.
 
     
    