#761 – How FlowDirection Affects HorizontalContentAlignment
February 21, 2013 Leave a comment
The FlowDirection property, which can be LeftToRight or RightToLeft, indicates how elements within a control should be layed out.
A FlowDirection of RightToLeft reverse the meaning of all HorizontalContentAlignment values. The example below shows the effect of different combinations of HorizontalContentAlignment and FlowDirection for some Label controls.
<Grid ShowGridLines="True"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Label Content="HorizontalContentAlignment / FlowDirection Values" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center"/> <Label Content="Left / LeftToRight" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="Bisque"/> <Label Content="Left / RightToLeft" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" FlowDirection="RightToLeft" Background="Bisque"/> <Label Content="Right / LeftToRight" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right" Background="Bisque"/> <Label Content="Right / RightToLeft" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right" FlowDirection="RightToLeft" Background="Bisque"/> </Grid>