views:

70

answers:

1

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)?

EDIT:

@meagar: thanks for the correction sir ^_^

+1  A: 

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();            
}
Wonko the Sane
yeah that's what i was trying to ask : minimize the main window while the modal dialog is up. so it's a no way eh? i'll leave the question up for some times though hoping one have a workaround.
dnr3
Out of curiosity - why would you want to do this? The reason not to do it is because it is standard behavior, meaning it behaves like all applications should behave. There is probably a way to hack it, but unless there is a good reason to, why would you force your application to behave in a way that is counter to a standard that has been established?
Wonko the Sane
it's definitely the client's request that made me put this up.
dnr3
A modal dialog is just that. By definition, it is the dialog that has focus, preventing interaction with the window that owns it. You can open the dialog non-modally (using dialog.Show()) if there must be interaction. Of course, this means that you have to make sure that the main window doesn't allow you to do anything that you need to be logged in for. It really makes very little sense from a design standpoint.
Wonko the Sane
so there's really no work around for this?
dnr3
Modal? No, not really. It is against the design principles of a modal dialog. Modeless? Sure.
Wonko the Sane
thanks for the confirmation sir, i'll just mark this as an answer then eventhough i hope there's someone who can get the workaround for this T_T
dnr3