Advertisement
Beginner .NET MAUI, XAML & UI Layouts

Compare StackLayout, VerticalStackLayout, and HorizontalStackLayout.

Short answer

VerticalStackLayout and HorizontalStackLayout are optimized single-orientation layouts introduced in MAUI; they are faster because they don't measure both orientations. StackLayout still exists with an Orientation property but is less performant.

Save .NET MAUI mock interview
Advertisement
AModel answer
VerticalStackLayout and HorizontalStackLayout are optimized single-orientation layouts introduced in MAUI; they are faster because they don't measure both orientations. StackLayout still exists with an Orientation property but is less performant. Prefer the dedicated layouts unless you need to switch orientation at runtime.
<VerticalStackLayout Spacing="10">
    <Label Text="Row 1" />
    <Label Text="Row 2" />
</VerticalStackLayout>
Real-world example
Replacing StackLayout with VerticalStackLayout in a long form measurably reduces layout time during scrolling.
Likely follow-ups
  • Why are the dedicated layouts faster? | When would you still use StackLayout?
Related topics