End / Exit WPF application

I create some WPF application. I am not sure why after I clicked on the Close icon. It just hides the application, instead of close/exit the application properly. E.g. I can still see the application name on Task Manager after I closed it.

I added 1 more lines of code to ensure my application closed properly.

Here it is the way I did.
On the WPF form, I look for the Window_Closed Event and double click on it. Then it will generate the code which to handle this event.

Then I just added a line on it to force the program to shut down whenever the user click on the close button ([X])

C# code
private void Window_Closed(object sender, EventArgs e)
{
Application.Current.Shutdown();
}

VB.Net code
Application.Current.Shutdown()

Happy Programming

Leave a Reply