开发者

UIElement's Visibility control from different UIElement

开发者 https://www.devze.com 2023-04-01 18:11 出处:网络
I have two UIElements X (X.xaml, Name=\"_X\") and Y (Y.xaml, Name=\"_Y\"). How can I control Visibility开发者_运维百科 of Y.xaml from X.xaml.cs?

I have two UIElements X (X.xaml, Name="_X") and Y (Y.xaml, Name="_Y"). How can I control Visibility开发者_运维百科 of Y.xaml from X.xaml.cs?

It's easy to control Visibility of Y.xaml from Y.xaml.cs, as I can use _Y.Visibility = SOMETHING, but I don't know how to do that from X.xaml.cs.


This is a common programming question about accessing the properties/members of one class from within another.

You need to grab a hold of a reference to the instance of the class you're trying to access. That depends on how they are created and how they related to each other in terms of object graph. Do they share the same parent, etc?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号