C # WPF Disable Exit / Close Button

Can I disable the close button in a WPF form? How to disable the close button?

I searched and found a solution below. But this only works on Windows Form!

private void Form1_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; } 
+4
source share
2 answers

in wpf, this event is 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; } 
+13
source

To do this, you need to capture windows. See this MSDN entry for details.

+1
source

All Articles