WPF uses the system's highlight color to paint the background of selected text. I would also like to redefine it.
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 to change this template to override the selected text and background color?
source share