Ugrás a tartalomhoz

.NET Programming Technologies

Gergely Kovásznai, Csaba Biró

Eszterházy Károly College

StackPanel

StackPanel

The StackPanel is one of the simplest among layout controls, in many cases the most useful layout control. It places its inside elements list-like arrangement (one under the other). It is enought to give the height of the elements, because their width is adapted to the StackPanel width.

To demonstrate the operation of the StackPanel, look at the following two examples:

Example IV.2 StackPanel

IV.2. StackPanel

<StackPanel Width="100">

    <Button Height="20" Content="Button 1" Margin="10"/>

    <Button Height="20" Content="Button 2" Margin="10"/>

    <Button Height="20" Content="Button 3" Margin="10"/>

</StackPanel>

If you would like to visualize the elements arranged next to each other (Orientation =”Horizontal”), it is enough to give the width of the elements.

Example IV.3 StackPanel

IV.3. StackPanel

<StackPanel Height="20" Orientation="Horizontal">

    <Button Width="100" Content="Button 1" Margin="10 0 10 0"/>

    <Button Width="100" Content="Button 2" Margin="10 0 10 0"/>

    <Button Width="100" Content="Button 3" Margin="10 0 10 0"/>

</StackPanel>