c# - ShowDialog not showing WPF -


current.shutdownmode = shutdownmode.onexplicitshutdown;  var dialog = new login();  dialog.showdialog();  var mainwindow = new mainwindow(dialog.success, dbinteraction.getpid(dialog.txtloginuser.text));  mainwindow.showdialog();  this.mainwindow = mainwindow;  if (mainwindow.showdialog() == true) {  } 

strange thing window never gets shown if debug jumps on showdialog points , not show them @ all. login shown fine.

as can see tried various recommend in other threads regarding topic this.mainwindow = mainwindow , setting shutdownmode explicit.

full call:

/// <summary> /// interaktionslogik für "app.xaml" /// </summary> public partial class app : application {     private void applicationstart(object sender, startupeventargs e)     {          current.shutdownmode = shutdownmode.onexplicitshutdown;         var dialog = new login();          dialog.showdialog();          var mainwindow = new mainwindow(dialog.success, dbinteraction.getpid(dialog.txtloginuser.text));          mainwindow.showdialog();          this.mainwindow = mainwindow;          if (mainwindow.showdialog() == true)         {          }     } } 

app.xaml

<application x:class="boosting.app"          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"          startup="applicationstart"          shutdownmode="onexplicitshutdown"> <application.resources>  </application.resources> </application> 

this need in case didn't :

  1. remove startupuri application xaml file

  2. set startup handler in app xaml :

  3. add show() mainwindow after dialog show :

    private void applicationstartup(object sender, startupeventargs e) {    current.shutdownmode = shutdownmode.onexplicitshutdown;    var dialog = new login();    dialog.showdialog();    var mainwindow = new mainwindow();    mainwindow.showdialog(); } 
  4. one last step. wpf set first created window mainwindow in app. show inside login.xaml.cs set mainwindow null next windows created takes precedence.

        if (app.current.mainwindow == this)     {         app.current.mainwindow = null;     } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -