WPF showing dialog before main window

后端 未结 6 659
无人共我
无人共我 2020-12-03 02:49

How one can show dialog window (e.g. login / options etc.) before the main window?

Here is what I tried (it apparently has once worked, but not anymore):

6条回答
  •  执笔经年
    2020-12-03 03:13

    If you put Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; into the constructor of the dialog, and add

    protected override void OnClosed(EventArgs e) {
        base.OnClosed(e);
        Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
    }
    

    into the dialog class, you don't need to worry about making any changes to the default behaviour of the application. This works great if you want to just snap a login screen into an already-existing app without tweaking the startup procedures.

提交回复
热议问题