Open harinikmsft opened 7 years ago
good, also need Visibility
.
would be nice to group and define such things in interfaces (and in more interfaces that just extend several interfaces to group them)
e.g. IHitTestVisible, ISizable, etc.
unless this incurs too much overhead. Wouldn't mind having a special kind of inline(d) interfaces that are just used at compile time btw. (similar to how TypeScript interfaces work)
IsVisible
Please don't do this but use Visibility
. IsVisible
has a much more important connotation in WPF, and one that is sorely missing in UWP/Forms. It's a calculated read-only boolean telling you if the control is currently visible in the tree, and is driven by whether it is rooted in the visual tree, whether it is loaded, and whether itself or any of its parents are visible, and is also joined by an IsVisibleChanged
event that control developers can listen to, and for instance stop rendering expensive DirectX/OpenGL when the control is no longer visible.
I realize Xamarin.Forms already messed up and is using 'IsVisible', but that's the framework that needs to fall in line.
@birbilis What purpose would these interfaces serve? How would you code against them in a concrete use-case? Why isn't say "HitTestVisible" on the base class not sufficient? Why would control developers implement this interface, rather than just inherit it?
Visibility has run it's course. Unless there are plans to bring back Hidden
the IsVisible
property is so much easier to use
You already got implicit conversion from boolean, and this change wouldn't add any new capability - on the contrary it would just introduce a second property to do the same thing introducing a confusing mess. Was it a poor design choice with the enum? Perhaps, but it's kind of a moot point at this point.
Also as mentioned 'IsVisible' already means something different and quite important and only becomes more important with defer-load.
If you have a control hierarchy you don't necessarily need interfaces. With those you can skip hierarchies or bridge different ones. However, if they're for runtime too they're probably expensive
This ties into #11 for Padding/Margin/Border/CornerRadius as well.
IsVisible
should mean visible to the user, not to the rendering engine. Maybe we should rename that one?
btw, regarding Visibility, I see in UWP only Visible and Collapsed values available. Wasn't there also a Hidden state in WPF where the control isn't visible but takes part in layout? Also, when using Collapsed what are the semantics? Is the control added to a graphics peer from the begging (when interoperating with native/media stuff sometimes this is needed) or lazy added? With hidden I suppose the semantics are to have it added to a peer (not sure what the terminology is in UWP about such stuff though)
Introduce more P/M/Es that are common across all relevant controls/panels etc.,
Opacity
IsVisible
MinWidth, MinHeight
IsHitTestVisible
DataContext
SizeChanged event