Home > DeveloperSection > Forums > Disable the exit/close button in C# WPF.
john rob

Total Post:108

Points:756
Posted on    July-19-2013 3:07 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 8852  View(s)
Rate this:

Is it possible to disable the close button in a WPF form? How can I disable the close button?

I have been searching around and found the solution below. But that works only in Windows Form!

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

      e.Cancel = true;

}



Vijay Shukla

Total Post:100

Points:700
Posted on    July-19-2013 6:24 AM

in wpf this event called Closing :

public Window4()

    {

        InitializeComponent();

        this.Closing += new System.ComponentModel.CancelEventHandler(Window4_Closing);

    }

    void Window4_Closing(object sender, System.ComponentModel.CancelEventArgs e)

    {

        e.Cancel = true;

    }


Don't want to miss updates? Please click the below button!

Follow MindStick