Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute code when a WPF closes

I am not familiar with using event handlers, and I was wondering if anyone had or could direct me to some code that shows how to use an event handler that will execute code on the Close/Closed event?

I know this can be done because of this answered question:

Run code on WPF form close

But I need some direction.

Thank you =)

like image 817
Stylzs05 Avatar asked Apr 04 '12 19:04

Stylzs05


1 Answers

It's just this XAML

<Window ... Closing="Window_Closing" Closed="Window_Closed">     ... </Window> 

and code for both the Closing and Closed events

private void Window_Closing(object sender, CancelEventArgs e) {     ... }  private void Window_Closed(object sender, EventArgs e) {     .... } 
like image 72
Clemens Avatar answered Sep 23 '22 08:09

Clemens