StackPanel layout is another one of the widely used layouts but its behavior differs from other layouts. As the name speaks (Stack), it can stack child elements vertically or horizontally. Thus, you can find it neat and you do not need to adjust the position manually.
Stack Horizontally
One scenario that I can think of is Horizontal Menu Bar. Let’s look at the sample screenshot below for more feel of it.
XAML
<StackPanel Orientation="Horizontal" x:Name="stackPanel_Name" HorizontalAlignment="Right" Margin="0,5,0,0">
…
</StackPanel>
Stack Vertically
I used this quite often when I was creating shadow effect or reflection effect, and it works perfectly. Let’s look at the next screenshot.
XAML
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
…
</StackPanel>
No comments:
Post a Comment