Quantcast
Channel: Aligning controls on both left and right side in a stack panel in WPF - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by Gregory Bologna for Aligning controls on both left and right side in a stack panel in WPF

$
0
0

Use the Stackpanel orientation type in a nested fashion as shown in the sample. The Grid Width is set to a parent width in order to achieve full width.

<StackPanel x:Name="stackBlah" Orientation="Vertical"><StackPanel Orientation="Horizontal"><Grid Width="{Binding ActualWidth, ElementName=stackBlah}" ><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition /></Grid.RowDefinitions><StackPanel Grid.Column="0" HorizontalAlignment="Left" ><Button Content="Some button" /></StackPanel><StackPanel Grid.Column="1" HorizontalAlignment="Right"><ToggleSwitch Header="Some toggle" AutomationProperties.Name="ToggleNotifications"/></StackPanel></Grid></StackPanel></StackPanel>

Viewing all articles
Browse latest Browse all 6

Trending Articles