DISABLE THE EXIT/CLOSE BUTTON IN C# WPF.

john rob

Total Post:108

Points:756
Posted by  john rob
WPF 
WPF
 11656  View(s)
Ratings:
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;
}
  1. Vijay Shukla

    Post:100

    Points:700
    Re: Disable the exit/close button in C# WPF.

    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;
        }

      Modified On Mar-30-2018 05:31:14 AM

Answer

NEWSLETTER

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