Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:

C#
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!!
Posted

1 solution

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[^].
 
Share this answer
 
Comments
Gianluca Palmieri 10-Jan-13 3:57am    
Yes but my problem is that when i press close button i don't want to close the application but only the single window.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900