我正在创建一个 WPF 应用程序并使用 WPF 扩展工具包库。我已将 IntegerUpDown 控件添加到我的 UserControl 中,当用户在文本框内按下时,我希望背景颜色从深灰色变为浅灰色。
我尝试在 xaml 中添加一个样式触发器,该触发器在 IntegerUpDown 控件 IsFocused 用于背景更改时触发。但是,这似乎不起作用。
<xctk:IntegerUpDown x:Name="Day" Value="{Binding DayText, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Style="{StaticResource IntegerUpDownStyle}" Minimum="{Binding MinimumDateSelection}" Maximum="{Binding MaximumDateSelection}">
<xctk:IntegerUpDown.Watermark>
<TextBlock Text="Day" Foreground="{StaticResource OffsetWhiteBrush}" Margin="0,0,60,0"/>
</xctk:IntegerUpDown.Watermark>
</xctk:IntegerUpDown>
<!-- Textbox and PasswordBox base styling for login boxes -->
<Style x:Key="IntegerUpDownStyle" TargetType="{x:Type Control}" BasedOn="{StaticResource BaseTextStyle}">
<Setter Property="MaxWidth" Value="400" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="{StaticResource FontSize20}" />
<Setter Property="FontFamily" Value="{StaticResource LatoRegular}" />
<Setter Property="Background" Value="{StaticResource DarkGreyBrush}" />
<Setter Property="Margin" Value="0,20,0,0" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="{StaticResource LightGreyBrush}" />
</Trigger>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
通过我添加的样式,我希望控件的背景从深灰色变为浅灰色,但没有发生任何事情。我怎样才能做到这一点?
陪伴而非守候
万千封印
DIEA
相关分类