简体   繁体   中英

Silverlight - determine if UserControl is visible to the user

I have a usercontrol in my Silverlight 5 Application. This UserControl can be placed on any other control (perhaps on a TabItem, a Panel etc.). I does now have to determine, if the UserControl is visible to the User. This should only be true, when the UserControl or some region of it are visible to the user. This sould be false for example, when the UserControl is on a TabItem which is in background or the UserControl is on a collapsed panel etc. Can I get this information out of the VisualTree? Thanks for any hints.

Setting the visibility can be done with the code below:

MyItem.Visibility = Visibility.Visible;

Normally, when placing an item inside a tabcontrol, the visibility value of it depends on the active tab, changing tabs will result in seeing the tabs value, while not giving the other tabs values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM