HOW TO CATCH THE EVENT OF THE WINDOW CLOSE BUTTON (RED X BUTTON ON WINDOW RIGHT TOP CORNER) IN WPF FORM?

Madam Walker

Total Post:22

Points:154
Posted by  Madam Walker
WPF 
WPF
 5268  View(s)
Ratings:
Rate this:

How to catch the event of the window close button (red X button on window right top corner) in wpf form?

How to catch the event of the window close button(red X button on window right top corner) in wpf form ? We have got the closing event, window unloaded event also, but we want to show a pop up if he clicks the close button of the wpf form.

Help me Please.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: How to catch the event of the window close button (red X button on window right top corner) in wpf form?

    Use the Closing event in the Window, you can handle it like this to prevent it from closing:

    private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)

    {

        e.Cancel = true;

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!