How to find out when the control is visible to the user?

I would like to know how to determine when the control is visbile to the user and when not?

Let it say that I am writing a custom control that extends TextBox, and I would like to know when it is visible, to make some kind of user logic inside the handler caused by the visible change.

How to do it? How do I find out if a control is visible to the user or not? A user control that extends TextBoxcan be inside Button, and Buttoncan receive Visibility.Collapsed, so all of its internal nested controls will be invisibe and this is what I want to know. How to determine if any value for the Visibility property is visible?

+5
source share
1 answer

You must use the UIElement.IsVisibleChangedevent. This happens when the value IsVisiblechanges, this dependency property is read-only and indicates Visibility elements in the user interface.
UIElement.LayoutUpdated- An event that can be used to recalculate the visibility of controls.

UPDATE This seems to be an exact duplicate:
In WPF, how can I determine if the control is visible to the user?

+9
source

All Articles