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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Mar 10, 2011, 10:09 AM
NiveditaPosted Mar 8, 2011, 6:54 AM
VulpesPosted Mar 8, 2011, 5:55 AM
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;
}
Suthish NairPosted Mar 8, 2011, 5:26 AM