Hi all
I want to write some functionality on closing a wpf application. How to do it for WIndow close button which is there in the top right corner of a window.
Thanks in advance
How to write code for window close button
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Suthish NairRank #92 · 22.8K reputationPosted Mar 8, 2011, 12:26 AM EST
VulpesRank #55 · 29.2K reputationPosted Mar 8, 2011, 12:55 AM EST
private void Window_Closed(object sender, EventArgs e)
{
MessageBox.Show("Goodbye!"); // or whatever
}
If you might want to prevent the window from closing in certain conditions, then you could handle the Closing event instead:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (someCondition) e.Cancel = true;
}
Nivedita72 reputationPosted Mar 8, 2011, 1:54 AM EST
Suthish NairRank #92 · 22.8K reputationPosted Mar 10, 2011, 5:09 AM EST