1

How i can minimize window from page?

I tried to do this, but it crashes the program.


private void minimizeBtn_Click(object sender, RoutedEventArgs e)
        {
           (this.Parent as Window).WindowState = WindowState.Minimized;
        }

Actaeon
  • 11
  • 1
  • You can use the `static Window.GetWindow()` method, see also https://stackoverflow.com/questions/302839/wpf-user-control-parent – Stefan Wuebbe Nov 30 '22 at 21:48

1 Answers1

0

You can minimize the current window via Page as:

private void minimizeBtn_Click(object sender, RoutedEventArgs e)
{
    Window.GetWindow(this).WindowState = WindowState.Minimized;
}
Grigory Zhadko
  • 1,484
  • 1
  • 19
  • 33