I expect this sample code to create 3 nested boxes with each box centered within its parent. My understanding is based on What is the difference between Xamarin.Form's LayoutOptions, especially Fill and Expand?. The boxes seem to be centered horizontally but not vertically.
Full repo: https://github.com/pawelpabich/Xamarin-Forms-Nested-Content
Sample Code:
var mainPage = new ContentPage();
var content = new StackLayout()
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
BackgroundColor = Color.Yellow,
HeightRequest = 200,
WidthRequest = 200,
Children =
{
new StackLayout()
{
BackgroundColor = Color.Blue,
HeightRequest = 100,
WidthRequest = 100,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new StackLayout()
{
BackgroundColor = Color.Green,
HeightRequest = 50,
WidthRequest = 50,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
}
}
}
}
};
mainPage.Content = content;
MainPage = mainPage;
End result when the app is running on a windows emulator:
.