tags:

views:

20

answers:

1

In my application I call App.Current.MainWindow.Show()/App.Current.MainWindow.Hide() to show/hide my application but I don't know how to catch the event when the form is hidden/showed. Please help if you know how to!

+1  A: 

One of your tags is WPF and the other is WinForms... I'm better with WinForms, so I'll answer for that tag.

The Form.Shown event documentation is here with sample code...

There is no corresponding Form.Hidden event. The best you can do is choose from Form.Closing or Form.Closed or one of the other events.

Added from my comment above

Question - if you're CALLING the Hide and Show in your code, why do you need to capture the events? You already KNOW when it's happening. If you want to run some code inside the form after hiding and closing it, expose the code as a public function, and call the function after showing and hiding the form...

David Stratton