2
以下のXAMLを使用して、ウィンドウ内のすべてのTextBoxの境界を赤色のOnMouseOverに設定しようとしています。マウスがテキストボックスの上にあるとき、FontSizeとForegroundのプロパティは設定されていますが、BorderBrushは以前のデフォルト値に戻す前に一時的にのみ設定されます。私は、BorderBrushをマウスがテキストボックスの上になくなるまで赤くしておきたい。これがどうして起こるのか?WPF BorderBrush on TextBoxは、一度IsMouseOverトリガに設定されています。
<Window x:Class="StylesApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Width" Value="250" />
<Setter Property="Height" Value="50" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="Red" />
<Setter Property="BorderBrush" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<TextBox>
My TextBox
</TextBox>
</Grid>
</Window>