Hi,
I use the RowDeletedEvent to validate if it's permitted to erase a data or put it in history depending of user choice :
RowDeletedEvent.Subscribe(OnRowDeleted, this.Table);
This is an async method and I try to set a property on my window before calling ShowDialog and nothing happing because of cross thread calling.
Example:
await QueuedTask.Run(() =>
{
ProWindowClass pwc = new ProWindowClass();
pwc.SetShowDateInput(Visibility.Visible);
pwc.ShowDialog();
});
The dialog is not showing up. But if I put in comment SetShowDateInput, the dialog is showing up.
I tried to use a async method for SetShowDateInput and use his own Dispatcher and I always got this error: The calling thread cannot access this object because a different thread owns it.
What is the best practice to set control property of ProWindow during an event calling a await method?
Thank you,
Jean
Ok I finally found how to call my Form, set parameters and call ShowDialog.
I needed to pass through FrameworkApplication.Current.Dispatcher.Invoke
Windows.DemandeSuppressionHistorique.ChoixEnum choix = Windows.DemandeSuppressionHistorique.ChoixEnum.Annuler;
FrameworkApplication.Current.Dispatcher.Invoke(() =>
{
Windows.DemandeSuppressionHistorique wnd = new Windows.DemandeSuppressionHistorique();
wnd.DemandeSupressionIsEnable(false);
wnd.ShowDialog();
choix = wnd.Choix;
});
Hope that could help someone eventually!
Jean