Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to figure out when control is visible to user?

Tags:

wpf

I would like to know how to figure out when a control is visbile to user and when not?

Let says I am writing a custom control which extends a TextBox and I would like to know when is visible to do some custom logic inside the handler triggered on visible changed.

How to do so? How to figure out if the control is visible to user or not? The custom control which extends a TextBox could be inside a Button for instance and Button could receive Visibility.Collapsed so all its inner nested controls would be invisibe and thats what I want to know. How to figure out if visible no matter what value to Visibility property is set?

like image 502
snowy hedgehog Avatar asked Feb 25 '13 11:02

snowy hedgehog


1 Answers

You should use UIElement.IsVisibleChanged event. It occurs when value of the IsVisible changes that is read-only dependency property and indicates elements Visibility on UI.
UIElement.LayoutUpdated - event that could be used for recalculating controls visibility.

UPDATE. Seems like it is exact duplicate:
In WPF, how can I determine whether a control is visible to the user?

like image 124
Anatolii Gabuza Avatar answered Sep 21 '22 00:09

Anatolii Gabuza