Replies: 1 comment
-
There is a related bug (see #21917) that would be good to be fixed: WidthRequest does not contain margins, but MaximumWidthRequest does, so |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I'd like to have an additional horizontal layout option that makes the control try to use as much space as possible, subject to MaximumWidthRequest, like Fill, but honoring Start / Center / End HorizontalOptions. Fill seems to be always Center aligned, if it hits MaximumWidthRequest. This could be a boolean option named HorizontalExpansion, which defaults to False.
And the same vertically.
This is a bit like what
*AndExpand
layout options are doing in StackLayout. Currently, it is impossible to make a resizing End-aligned button that is, say, 200 wide, but does not expand beyond container boundaries, which is a basic case in Xamarin withWidthRequest="200" HorizontalOptions="End"
.An alternative would be to make
*AndExpand
to work for other controls in addition to StackLayout. This might result in layout changes from Xamarin, but could be more intuitive. I like the new MaximumWidthRequest, but it really needs to be paired with an option to force expansion / fill while preserving Start / Center / End layout option (so changing that to Fill won't do).Public API Changes
var button = new Button();
button.HorizontalOptions = LayoutOptions.End;
button.MaximumWidthRequest=200;
button.HorizontalExpansion=true;
Intended Use-Case
I like to make a basic button that is End-aligned, is 200 wide, and honors container boundaries, like what I got with Xamarin when I had WidthRequest="200" and HorizontalOptions="End". This would help with migrating from Xamarin to .NET MAUI.
Beta Was this translation helpful? Give feedback.
All reactions