Replies: 1 comment 1 reply
-
Just adding some options here
Avalonia and UWP have This event provides more complete result than Bounds, as goes through every ancestor boundaries/clip. Yet, it's not complete enough, as it only can read/respect UI thread (i.e. - layout) information.
What's wrong with Loaded event? Although, neither (loaded/render method) indicate moment of first frame drawn with this element. |
Beta Was this translation helpful? Give feedback.
-
This topic comes up from time-to-time. There isn't really a good way to tell if a control is ACTUALLY visible to the user on the screen. By "actually visible" I mean drawn on the screen where the user can see it -- not clipped, hidden, etc. -- actually there on the screen.
Here is the topic from the WinUI repo which has further discussion about this: microsoft/microsoft-ui-xaml#674
Now in that discussion I don't recall the topic of automation API's coming up. However, the automation APIs of course need this information themselves to figure out what to announce to users. Therefore, we have the
IsOffscreen
property and certain modes get us most of the way there.However, what is everyone's opinion about:
This is all helpful in some use cases where you only want to do certain expensive operations or perhaps UI animations/updates when a control is actually shown to the user.
Note that this functionality can be achieved by watching the Bounds property right now. That method is used in some third party controls as well. If Bounds.Size is (0,0) the control isn't shown yet. When the Bounds has an actual value you can assume it is now visible. Composition/Rendering is efficient and already has the needed information.
Beta Was this translation helpful? Give feedback.
All reactions