i've got window besides mainwindow in application , override closing-method because don't want window closed:
private void window_closing(object sender, canceleventargs e) { e.cancel = true; this.visibility = visibility.hidden; }
then in constructor:
public inputwindow() { initializecomponent(); this.closing += window_closing; }
but if want close mainwindow, hides mainwindow.
can't figure out, how work.
every wpf application has property called application.shutdownmode, determines when application ends. default, set onlastwindowclose, means application won't end until windows closed (even if main window closes). sounds want application end when main window closes if other windows not closed, hidden, correspond onmainwindowclose mode. here relevant msdn documentation: https://msdn.microsoft.com/en-us/library/system.windows.application.shutdownmode(v=vs.110).aspx
to set property in xaml, open app.xaml file , add shutdownmode property this:
<application x:class="testclass" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" shutdownmode="onmainwindowclose"> </application>
Comments
Post a Comment