5
votes

I have an application which on the first load it will show a modal window for user login (a borderless window). Now when the user wants to minimize the application by clicking the minimize button of the main window, it can't be done cause the main window is locked by the modal window. When the user tries to click the application taskbar it still won't minimize.

How can I allow the application to be minimized when a modal is showing (using the main window taskbar)?

1

1 Answers

4
votes

Your question is a little unclear to me. If you mean, can you minimize the main window while the modal dialog is up, then, no - the modal dialog has control (and that's the purpose of a modal dialog).

However, you can minimize the main window (or hide it, or whatever) before you show the dialog:

void btnLogin_Click(object sender, RoutedEventArgs e)
{
    MyLoginDialog dialog = new MyLoginDialog();
    dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
    dialog.WindowState = WindowState.Normal;

    this.WindowState= WindowState.Minimized;
    // Can also do this to completely hide the main window:
    // this.Visibility = Visibility.Collapsed;

    dialog.ShowDialog();            
}