Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsEffectivelyVisible should be a proper property just like IsEffectivelyEnabled is #15413

Open
AlexeyTliss opened this issue Apr 17, 2024 · 1 comment

Comments

@AlexeyTliss
Copy link

Is your feature request related to a problem? Please describe.

The problem is: control doesn't know when it becomes invisible due to it's parent IsVisible being changed to false.
This causes me problem with two cases:

  1. I tried to design a control which plays an animation when becomes visible. This worked fine if you manipulate IsVisible of the control itself, but broke if you change IsVisible of parent control
  2. I deisgn an Ui Voice Control Engine and parse logical tree to search for controls which spawn content like ItemsControl and ContentControl, and subscribe to its events to know when their content is changed and I need to re-parse it. The problem is, if content is changed when control is not visible, the content is not actually spawned, and despite event being fired, I will load nothing by parsing them, until they becomes Visible, and I can't monitor their Visibility, unless it is directly controlled

Describe the solution you'd like

I would very much prefer IsEffectivelyVisible being an actualy property just like IsEffectivelyEnabled which can be monitored via PropertyChanged event

Describe alternatives you've considered

The current workaround is to subscribe to IsVisible change of every logical parent of control in tree, which is hacky and very unstabled solution for obvious reasons

Additional context

No response

@grokys
Copy link
Member

grokys commented Apr 17, 2024

I'd be hesitant to do this because of the performance overhead: the property change handler will have to be called for potentially the entire visual tree each time the property value changes, even if the property has no listeners (we don't know what people are doing in their OnPropertyChanged/PropertyChanged handlers so have to raise the event whether there are subscribers or not). Visiblility changes are a lot more common than enabled changes.

A potential alternative solution would be to add an EffectivelyVisibleChanged CLR event: this way we can explicitly tell when there are subscribers and avoid the overhead when there are none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants