c# - How to prevent application shutdown on close window? -


i'm using wpf , i've got no main window (i've overwritten onstartup method). when user clicks on menu-item, want show settings window.

app.xaml.cs:

protected override void onstartup(startupeventargs e) {     base.onstartup(e);      new mainenvironment(); } 

mainenvironment.cs:

notifyicon notifyicon; settings settings_wnd = new settings(); // wpf window  public mainenvironment() {     notifyicon = new notifyicon()     {         ...          contextmenu = new contextmenu(new menuitem[]         {             new menuitem("settings", contextmenu_settingsbutton_click)         })     }; }  void contextmenu_settingsbutton_click(object sender, eventargs e) {     if (!this.settings_wnd.isvisible)         this.settings_wnd.show();     else         this.settings_wnd.activate(); } 

problem when user closes window, whole application exits too. why? , how can prevent that?

thanks

the application defaultly set shutdown when windows closed. need add shutdownmode="onexplicitshutdown" app.xaml file.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -