Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 views
in Technique[技术] by (71.8m points)

event handling - 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 =)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)
{
    ....
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...