How to get the minimize box click event of a WPF window?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s an event called
StateChangedwhich (from the help) looks like it might do what you want.The help says it’s only supported in .NET 3.0 and 3.5 under Vista, but I’ve just tried it on XP and it fires when the window is minimized, maximized and restored. However, from my testing, it fires after the state has changed, so if you want to do something before the window minimized this might not be the approach you need.
You’ll have to check the actual state to make sure it’s correct.
Obviously if I was just printing out the state I’d use
this.WindowState.ToString()😉The following should get added to the XAML defintion of your window by Visual Studio: