You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The DialogHost.WaitForClosed() and DialogHost.WaitForOpened() methods don't wait until the closing/opening animation is actually finished.
Here is an example where the background is set to red after closing the dialog and using the new WaitForClosed() method:
mdixWaitFor.mp4
Repro:
privateasyncvoidButton_Click(objectsender,RoutedEventArgse){vardialogContent=newButton(){Content="Close",Margin=newThickness(400)};dialogContent.Click+=(_,_)=>DialogHost.Close("RootDialog");awaitDialogHost.Show(dialogContent,"RootDialog");varsw=Stopwatch.StartNew();awaitDialogHost.WaitForClosed("RootDialog");sw.Stop();Debug.WriteLine($"WaitForClosed: {sw.ElapsedMilliseconds}ms");// Do some UI workif(App.Current.MainWindow.Background==System.Windows.Media.Brushes.Red){App.Current.MainWindow.Background=System.Windows.Media.Brushes.Green;}else{App.Current.MainWindow.Background=System.Windows.Media.Brushes.Red;}}
The output shows the call to await DialogHost.WaitForClosed("RootDialog"); is not waiting for anything: WaitForClosed: 0ms
Bug explanation
related PR #4083
The
DialogHost.WaitForClosed()andDialogHost.WaitForOpened()methods don't wait until the closing/opening animation is actually finished.Here is an example where the background is set to red after closing the dialog and using the new
WaitForClosed()method:mdixWaitFor.mp4
Repro:
The output shows the call to
await DialogHost.WaitForClosed("RootDialog");is not waiting for anything:WaitForClosed: 0msVersion
latest main