StackPanel helps you in aligning the multiple controls in a horizontal or vertical sequence.
Consider a scenario where you have multiple controls aligned in a vertical manner.
For instance, as shown in the image below:
You can set it up in proper format by applying the margins and paddings.
But, all this work can be saved by the StackPanel.
To add StackPanel, follow the steps below:
Navigate to the TOOLBOX and drag the StackPanel from it on the form.
(Note, StackPanel does not hold any border, so you can see its visibility by hovering over it or selecting it)
Drag the controls inside the StackPanel and you will see they align vertically themselves.
Setting Horizontal Layout for StackPanel #
You can also align the controls in the StackPanel horizontally.
For that, the steps are:
Navigate to the Orientation under Common in the Properties tab.
Select Orientation as Horizontal. And it will setup the controls in StackPanel horizontally as shown below:
Properties, Methods and Events #
All of the properties, methods, and events can be found in Microsoft’s documentation at: