Get size from ShowDialog

538 Views Asked by At

The user may change the size and position of the NavigationWindow
I want to capture the Height, Width, Left, and Right when the user closes the dialog
How can I do that?

NavigationWindow help = new NavigationWindow();
help.Content = new PageHelp2("Fields");
help.Height = 600;
help.Width = 800;
help.ShowDialog();

The purpose is the next time they are shown help to bring it up with the last size and position.

1

There are 1 best solutions below

0
On BEST ANSWER

You can capture the moment a window is closing using the Window.Closing event or Window.Closed event. Be sure to read the remarks for the former, as the event won't always be raised.

public void ShowHelp()
{
    NavigationWindow help = new NavigationWindow();
    help.Closing += HelpWindow_Closing;
    help.Content = new PageHelp2("Fields");
    //
    help.ShowDialog();
}

void HelpWindow_Closing(object sender, CancelEventArgs e)
{
    var window = sender as Window;

    // Do your thing
    window.Height;
    window.Width;
}