Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override default window close operation?

Tags:

In WPF I want to change default close behaviour of some window, so that when user clics red close button the window does not close, it merely hides (and call some method as well). How can I do that?

like image 442
Rasto Avatar asked Jun 08 '10 21:06

Rasto


1 Answers

Try overriding OnClosing in Window.xaml.cs

private override void OnClosing( object sender, CancelEventArgs e ) {      e.Cancel = true;      //Do whatever you want here.. } 
like image 172
Jobi Joy Avatar answered Oct 21 '22 07:10

Jobi Joy