I am learning Maui and how it lays out its controls. In the little practice app I have going I extended Grid and was able to add it to an grid to display little vertical areas on my main screen.
However I was looking at adding some color and graphics but I cannot seem to get the Grid itself to take up the full area it has been assigned.
My code for the “wings” looks like this. Each wing in a grid area that 1 row and 15% of the screen.
public SideLayout(SideStackAlignment side)
{
_side = side;
Setup();
}
private void Setup()
{
RowDefinitions = new RowDefinitionCollection(new []
{
new RowDefinition(GridLength.Auto),
new RowDefinition(GridLength.Auto)
});
ColumnDefinitions = new ColumnDefinitionCollection(new[]
{
new ColumnDefinition(GridLength.Auto)
});
Rotation = _side == SideStackAlignment.Left ? 270 : 90;
HorizontalOptions = _side == SideStackAlignment.Left ? LayoutOptions.Start : LayoutOptions.End;
VerticalOptions = LayoutOptions.Center;
BackgroundColor = Color.FromArgb("#cccccc");
_title = new Label
{
HorizontalOptions = LayoutOptions.Center,
TextTransform = TextTransform.Uppercase,
FontFamily = "OpenSansRegular",
FontSize = 18,
TextColor = AppColors.TextColor
};
this.Add(_title, 0,0);
_detail = new Label
{
HorizontalOptions = LayoutOptions.Center,
TextTransform = TextTransform.Uppercase,
FontFamily = "OpenSansRegular",
FontSize = 30,
TextColor = AppColors.TextColor
};
this.Add(_detail, 0,1);
}
Any help would be appreciated. I like clarity of adding these custom controls via code instead of XAML due to future features, but cannot figure out why the gray background doesnt takeup the full “wing” area