The only way I can do this is to manually use the Rectangle declared before or with the contents of the string to set it in the opposite direction:
<Grid Background="White"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Rectangle Grid.Row="0" Fill="AliceBlue" /> <TextBlock Grid.Row="0" Text="Row 1" HorizontalAlignment="Center"/> <Rectangle Grid.Row="1" Fill="AntiqueWhite" /> <TextBlock Grid.Row="1" Text="Row 2" HorizontalAlignment="Center"/> <Rectangle Grid.Row="2" Fill="AliceBlue" /> <TextBlock Grid.Row="2" Text="Row 3" HorizontalAlignment="Center"/> <Rectangle Grid.Row="3" Fill="AntiqueWhite" /> <TextBlock Grid.Row="3" Text="Row 4" HorizontalAlignment="Center"/> </Grid>
Perhaps you can use the bindings to transfer the line number to the converter in order to return the correct color, rather than hard coding, as here.
source share