Skip to content

Commit 80fcc49

Browse files
Postpone DialogHost.Show() task completion until the animation finishes
1 parent 3f869b6 commit 80fcc49

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,14 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
358358
}
359359

360360
//NB: _dialogTaskCompletionSource is only set in the case where the dialog is shown with Show
361-
dialogHost._dialogTaskCompletionSource?.TrySetResult(closeParameter);
361+
if (dialogHost._dialogTaskCompletionSource is { } taskCompletionSource)
362+
{
363+
Task.Run(async () =>
364+
{
365+
await Task.Delay(400); // Wait for the closing animation to finish before completing the DialogHost.Show() task.
366+
taskCompletionSource.TrySetResult(closeParameter);
367+
});
368+
}
362369

363370
// Don't attempt to Invoke if _restoreFocusDialogClose hasn't been assigned yet. Can occur
364371
// if the MainWindow has started up minimized. Even when Show() has been called, this doesn't

0 commit comments

Comments
 (0)