2
WPF使用系統高亮顏色繪製選定文本的背景。我也想重寫它。如何更改TextBox的突出顯示的文本顏色?
我有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>
我怎樣才能改變這個模板覆蓋高亮顯示的文本和背景顏色?
謝謝!我使用SelectionBrush來更改所選文本的背景顏色。但我也需要改變選定的文字顏色。有沒有這樣做的可能性? – Diana
您不能:http://stackoverflow.com/a/10850718/37168 – stone