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.
1 Answer
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
}
1 Comment
Alexandre Veya
You can register in contructor