Using a stackpanel control in Silverlight XAML

The StackPanel control is a container control that allows you to add child controls similar to the Canvas and Grid controls. The StackPanel automatically lays out controls evenly either horizontally or vertically. The orientation of the StackPanel is configured by setting the Orientation property to either Vertical or Horizontal.

The following example uses a StackPanel to line up a group of RadioButton controls in a Canvas.

<Canvas x:Name=”LayoutRoot” Background=”LightGray”>
<StackPanel Background=”White”
Canvas.Top=”50” Canvas.Left=”50”
Height=”100” Width=”100”>
<RadioButton Content=”Option A”
<RadioButton Content=”Option B”
<RadioButton Content=”Option C”
<RadioButton Content=”Option D”

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.