Anyone knows how to return a value from Dispatcher.Invoke in wpf? I want to return the selected index for a ComboBox.
Thanks!
This is my method to retrieve selected value for a combobox, how can I say delegate to return value?
private object getValueCB(System.Windows.Controls.ComboBox cb)
{
object obj;
if (!cb.Dispatcher.CheckAccess())
{
obj = cb.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
obj = cb.SelectedValue;
}
));
return obj;
}
else
{
return obj = cb.SelectedValue;
}
}