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 :
remove
startupuri
application xaml fileset startup handler in app xaml :
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(); }
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
Post a Comment