Quantcast
Viewing latest article 1
Browse Latest Browse All 6

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

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 latest article 1
Browse Latest Browse All 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>