关闭WPF窗口但不关闭应用程序 [英] Close WPF Window but don't close application

查看:311
本文介绍了关闭WPF窗口但不关闭应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想关闭一个wpf窗口,但我不想关闭整个应用程序。我尝试覆盖OnClosing方法:



  protected  覆盖  void  OnClosing(CancelEventArgs e)
{
.OnClosing(E);
e.Cancel = true ;
}





但是当我按下关闭按钮时,窗口仍然在屏幕上。



你能帮我吗!!

解决方案

如果设置 e.Cancel = true; 你要求程序不要通过取消结束活动来关闭。

因此你的窗口仍然保持打开状态。



你可以最小化到任务管理器或通知托盘 [ ^ ]。

Hi, i wan''t to close a wpf window but i don''t want to close the entire application. I try to override OnClosing method:

protected override void OnClosing(CancelEventArgs e)
{
    base.OnClosing(e);
    e.Cancel = true;
}



but when I press close button the window remains on the screen.

Can you help me please!!

解决方案

If you set e.Cancel = true; you are asking the program not to close by cancelling the closing event.
Thus your window still remains open.

You can minimize to the task manager or to the notification tray[^].


这篇关于关闭WPF窗口但不关闭应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆