由于某些原因,只要鼠标悬停在文本框上,我的文本框边框就会将颜色更改为输出蓝色。这是我的xaml:
<TextBox
BorderThickness="1"
BorderBrush="Black"
x:Name="textBox"
custom:ScrollToEndBehavior.OnTextChanged="True"
VerticalScrollBarVisibility="Auto"
HorizontalAlignment="Center"
Height="154"
Margin="32,220,36,5"
TextWrapping="Wrap"
Text="{Binding LogText, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Width="449"
Background="WhiteSmoke"
Visibility="{Binding Path=IsLogVisible, Converter={StaticResource BoolToVis}}"
IsReadOnly="True"/>
答案 0 :(得分:1)
使用IsMouseOver触发器将默认样式更改为黑色:
<Style TargetType="TextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
Name="border"
SnapsToDevicePixels="True">
<ScrollViewer HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
Name="PART_ContentHost"
Focusable="False" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter Property="Border.BorderBrush" TargetName="border"
Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>