---
title: "Disable the exit/close button in C# WPF."  
description: "Disable the exit/close button in C# WPF."  
author: "Anonymous User"  
published: 2013-07-19  
updated: 2013-07-19  
canonical: https://www.mindstick.com/forum/1336/disable-the-exit-close-button-in-c-sharp-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# Disable the exit/close button in C# WPF.

Is it [possible to disable](https://www.mindstick.com/forum/34431/is-it-possible-to-disable-authorization-on-one-action-in-an-mvc-controller) the [close](https://yourviews.mindstick.com/story/1687/rubbing-hands-close-up-benefits) [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) in a [WPF](https://www.mindstick.com/forum/304/wpf) [form](https://www.mindstick.com/forum/6/multi-form-mfc-application)? How can I disable the close button?

I have been searching around and found the solution below. But that works only in [Windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) Form!

```
private void Form1_FormClosing(object sender,
FormClosingEventArgs e){      e.Cancel = true;}
```

## Replies

### Reply by Vijay Shukla

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;    }
```


---

Original Source: https://www.mindstick.com/forum/1336/disable-the-exit-close-button-in-c-sharp-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
