Skip to content

DialogHost.WaitFor* methods not waiting for animation to finish #4086

Description

@corvinsz

Bug explanation

related PR #4083

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:

private async void Button_Click(object sender, RoutedEventArgs e)
{
    var dialogContent = new Button()
    {
        Content = "Close",
        Margin = new Thickness(400)            
    };
    dialogContent.Click += (_, _) => DialogHost.Close("RootDialog");

    await DialogHost.Show(dialogContent, "RootDialog");
    var sw = Stopwatch.StartNew();
    await DialogHost.WaitForClosed("RootDialog");
    sw.Stop();
    Debug.WriteLine($"WaitForClosed: {sw.ElapsedMilliseconds}ms");

    // Do some UI work
    if (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

Version

latest main

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions