[Enhancement] Replace IsVisible with Visibility (similar to Android) #33
Replies: 12 comments 4 replies
-
While on the topic, all prior Microsoft UI platforms have used "Visible", "Hidden", and "Collapsed" as the three Visibility options. Would those be better to use since they are known to XAML devs? |
Beta Was this translation helpful? Give feedback.
-
public enum Visibility
{
Visible = 0,
Hidden = 1,
Invisible = 1,
Collapsed = 2,
Gone = 2
} |
Beta Was this translation helpful? Give feedback.
-
The exact name is less important. I think having both would be a mistake though. A new user looking at some XAML that included both |
Beta Was this translation helpful? Give feedback.
-
In WPF, it is Hidden. In UWP XAML, there is no Hidden and only Visible and Collapsed exists. If MAUI must include this support, I suggest Visible, Collapsed and Hidden naming as part of the .NET legacy. There should be no confusion for the new developers by introducing different names for the same functionality. |
Beta Was this translation helpful? Give feedback.
-
Since Maui is a XAML variant and XAML developers are familiar with the Visible/Collapsed naming (and WPF devs with the Hidden value), it seems like using those established standard names is best. I agree that using different names for the same value, while possible, would be confusing. It would be better to just state in documentation comments that Collapsed is "Gone in Android" etc. |
Beta Was this translation helpful? Give feedback.
-
I do like this proposal. Currently if I need to reserve the space for something but make it invisible, I have to have the OP's idea of continuing with Android's implementation makes the most sense since the intent is clear. public enum Visibility
{
Visible,
Invisible,
Gone
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Does iOS support this? They just have a |
Beta Was this translation helpful? Give feedback.
-
If iOS does not support one of the three options. Just implement the ones that are suported for iOS. What I meant to say is that if iOS does not have a hidden feature and keeping the layout intact, then do not fake it. Just document it and that is all. |
Beta Was this translation helpful? Give feedback.
-
I need this function as well. I see in Android, Maui's Sounds like in iOS, I want I see in the documentation: Line 116 in 87c9aac
I can see the enum here:
But I suspect what this is saying is if we use any default objects like Border/Layout/Image/Editor they will only have We have the Then we have the 3 option Which we can only https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.iview.visibility?view=net-maui-7.0#microsoft-maui-iview-visibility I also see in Android here is the implementation:
As far as I can tell we are screwed for trying to implement this ourselves as the line Why on earth would it be set up like this? The rot goes down to here:
Where again we cannot control our own visibility states it seems as Maui will only lock us to one of two choices every time something is updated. This makes no sense. Am I correct to think I would then have to replace all these methods myself on runtime with some insane method like this? https://stackoverflow.com/a/36415711 Why must we then jump through crazy hoops just to use basic essential functions? Using the Invisible modes are absolutely necessary in Android. How can we design anything without them? Have any Maui project managers ever built a significant Android app before? You will experience continuous 1-2 second lags whenever you hide or show something if you can't use the proper display toggling to optimize. As for iOS, I see from their literature:
https://developer.apple.com/documentation/uikit/uiview/1622585-hidden I am not clear which of the three states they are then describing. Either way this could then be mapped to whichever of the three behavior states it matches without any hassle. Why not then give us all three choices? As far as I can see the above are the only major things to change. |
Beta Was this translation helpful? Give feedback.
-
Maybe we deserve a render stack to put controls inside and it renders, we can say it's on or off or whatever but when we remove it from the stack it's really destoryed |
Beta Was this translation helpful? Give feedback.
-
Any updates from the MAUI team on implementing this feature? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Xamarin Forms uses a two state visibility system, something is visible or it is not. Android has a three state visibility system. The third state is not rendered, but is still used for layout. It would mainly be
Layout
s that care about this third state.API Changes
Backwards compatibility
IsVisible
would be deprecated.true
would map toVisible
andfalse
toGone
.Invisible
could go either way., since using bothIsVisible
andVisibility
in the same view hierarchy is likely to be broken (i.e. settingVisibilty
and gettingIsVisible
would not be recommended).One big caveat is whether this can be reasonably implemented - i.e. can all native renderers be correctly measured while invisible.
Intended Use Case
This can be useful in several situations, for example when something can be toggled visible or invisible, but is also not a predictable size. Using the
Invisible
state means the surrounding layout can be stable while the visibility is toggled.Beta Was this translation helpful? Give feedback.
All reactions