8

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;
}
EM10
  • 795
  • 7
  • 12
  • 24
  • 2
    look at this : http://stackoverflow.com/questions/743906/how-to-hide-close-button-in-wpf-window – Javidan Apr 21 '13 at 15:38

2 Answers2

18

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;
    }
user1064519
  • 2,180
  • 12
  • 13
1

You need to implement a windows hook to accomplish that. See this MSDN post for details.

David
  • 15,894
  • 22
  • 55
  • 66