WPF uses the system highlight color for painting the background of the selected text. I'd like to override it too.
I have a control template for textBox:
<ControlTemplate TargetType="TextBox">
<Border Name="Border"
CornerRadius="2"
Padding="2"
Background="Transparent"
BorderThickness="0" >
<ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="{StaticResource TextBoxDisabledBackgroundColor}"/>
<Setter Property="Foreground" Value="{StaticResource TextBoxDisabledForegroundColor}"/>
</Trigger>
<Trigger Property="IsReadOnly" Value="false">
<Setter TargetName="Border" Property="Background" Value="{StaticResource TextBoxBackgroundColor}"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
How can I change this template to override the highlighted text and background color?
I did it with styles, e.g.:
In .NET 4 you can use the SelectionBrush property of the textbox.
Earlier versions require you to override system colours in-code, as there was no easily-exposed property for this - the textbox would just use the system-defined values.