I'm using the following code to create and render a simple Label. The layout is set to have the same height and width as the screen.
maincontent = new Microsoft.Maui.Controls.AbsoluteLayout
{
BackgroundColor = Microsoft.Maui.Graphics.Color.FromArgb("#FF221E1F"),
HeightRequest = mainmescreenheight,
IsEnabled = true,
IsVisible = true,
WidthRequest = mainmescreenwidth
};
Microsoft.Maui.Controls.Label newLabel = new Microsoft.Maui.Controls.Label
{
BackgroundColor = Microsoft.Maui.Graphics.Color.FromArgb("#FF221E1F"),
FontAttributes = Microsoft.Maui.Controls.FontAttributes.Bold,
FontFamily = "VerdanaBold",
FontSize = 14,
HorizontalOptions = Microsoft.Maui.Controls.LayoutOptions.Center,
HorizontalTextAlignment = Microsoft.Maui.TextAlignment.Center,
IsEnabled = true,
IsVisible = true,
MinimumHeightRequest = 300,
MinimumWidthRequest = 640,
Text = "Center of Label",
TextColor = Microsoft.Maui.Graphics.Color.FromArgb("#FFFFFFFF"),
VerticalTextAlignment = Microsoft.Maui.TextAlignment.Center,
VerticalOptions = Microsoft.Maui.Controls.LayoutOptions.Center
};
AbsoluteLayout.SetLayoutFlags(newLabel, Microsoft.Maui.Layouts.AbsoluteLayoutFlags.None);
AbsoluteLayout.SetLayoutBounds(newLabel, new Rect(0, 0, 640, 300));
maincontent.Children.Add(newLabel);
I want the text, in this case "Center of Label" to appear both vertically and horizontally centered.
Although the text is always horizontally centered, it always appears at the very top of the label as if VerticalTextAlignment and VerticalOptions were set to .Start rather than .Center.
How do I get the text to center vertically? This is net7.0-windows10.0.19041.0.

Assuming
Your
AbsoluteLayoutsetup is the problem and the Min Height/Width is unnecessary.Below is how your code should look:
Also, I have no clue why you have
or
In your AbsoluteLayout.
AbsoluteLayout by default fits into its parent.