I want to set up an event to run when the Visibility is changed on a WPF Canvas control.
canvas1.VisibleChanged += new EventHandler(canvas1_VisibleChanged);
I have tried the above but it doesn’t work, anyone know how to do it ?
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.
You’re looking for the
IsVisibleChangedevent, which applies to ALL UIElements:UIElement.IsVisibleChanged
More Information:
IsVisibleis a read-only Dependency Property. It is a calculated value, and theVisibilityDependency Property affects it. This is what you should use to detect if you’reUIElementis visible or not.Now, if you really really wanna just check for the
VisibilityDP changing for whatever reason there is a way to do so: http://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/Though, I’d still stick with just tracking the
IsVisibleChanged.