How to override default window close operation?

后端 未结 3 1443
南方客
南方客 2020-12-10 01:58

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

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 02:04

    Try overriding OnClosing in Window.xaml.cs

    private override void OnClosing( object sender, CancelEventArgs e )
    {
         e.Cancel = true;
         //Do whatever you want here..
    }
    

提交回复
热议问题