I am trying to call a selected listbox item from a button, not the listbox.selecteditemchanged
method in wpf. So when i try
string yadda = listbox.SelectedItem.ToString();
i get an exception:
The calling thread cannot access this object because a different thread owns it.
So, what i was trying to do is the following:
Dispatcher.BeginInvoke(() =>
{
lbxSelectedItem = (lbxFileList.SelectedItem as TextBlock).Text;
});
That is not working either because i get another exception:
Cannot convert lambda expression to type 'System.Delegate' because it is not a delegate type