First of all, the xxxAndExpand attribute has been deprecated in MAUI, you can check the official document about the LayoutOptions.StartAndExpand Field.
But I tested your code on both xamarin and maui, the result were same.
The button will not expand to the frame unless I centre the text, which I don't want to do
Centering the text it the button't default behavior. If I change the StartAndExpand
to Fill
:
<Button Text="Get This Working" HorizontalOptions="Fill"/>
I got this:
And if you want the button fill the Frame and keep the button's text at the start. You need to call the platform code.
Give the button a name:
<Button x:Name="button" Text="Get This Working" HorizontalOptions="Fill"/>
And call the platform code in the code behind:
protected override void OnHandlerChanged() { base.OnHandlerChanged();#if WINDOWS var btn = button.Handler.PlatformView as Microsoft.Maui.Platform.MauiButton; btn.HorizontalContentAlignment = Microsoft.UI.Xaml.HorizontalAlignment.Left;#elif ANDROID var btn = button.Handler.PlatformView as Google.Android.Material.Button.MaterialButton; btn.TextAlignment = Android.Views.TextAlignment.ViewStart;#elif IOS var btn = button.Handler.PlatformView as UIKit.UIButton; btn.TitleLabel.TextAlignment = UIKit.UITextAlignment.Left;#endif }
And I got this:
Finally, the Frame was deprecated in MAUI, you can use the Border instead.