1

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 1

1

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
    }
Sign up to request clarification or add additional context in comments.

1 Comment

You can register in contructor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.