Reputation: 7805
I have a bunch of user controls in my application. When I close my application, I want to fire off some specific functions in each of these user controls one-by-one. Is this possible? The Unloaded
event doesn't seem to get fired on application close.
Upvotes: 1
Views: 398
Reputation: 95
You can register to
Application.Current.Exit
in each UserControl.xaml.cs:
public MyUserControl()
{
InitializeComponent();
Application.Current.Exit += CurrentOnExit;
}
private void CurrentOnExit(object sender, ExitEventArgs exitEventArgs)
{
Application.Current.Exit -= CurrentOnExit;
//Do what you want
}
Upvotes: 1