【发布时间】:2024-01-17 04:25:01
【问题描述】:
我使用 Telerik WPF 控件并且需要将 NumericUpDown 控件添加到我的 UI。问题是当“按原样”使用时,它在视觉上不适合应用程序的其余部分
<TL;DR>
This is a bigger application, that's not been written fully by me. Other people somehow managed to "import" other telerik controls and assign them other styles. Sadly, nobody's used the UpDown control before.
</>
我将控件添加到我的 UI:
<telerik:RadNumericUpDown
Minimum="0"
Maximum="10"
SmallChange="1"
NumberDecimalDigits="0"
IsInteger="True"
Value="{Binding Path=Counter}" />
此外,我还为 ResourceDictionary 添加了一些样式:
<Style TargetType="{x:Type telerikInput:RadNumericUpDown}">
<Setter Property="Padding" Value="1"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="Border.CornerRadius" Value="2" />
<Setter Property="Border.Background" Value="{StaticResource ControlBackgroundBrush}" />
<Setter Property="Border.BorderBrush" Value="{StaticResource SolidBorderBrush}" />
<Setter Property="Border.BorderThickness" Value="1" />
</Style>
这会处理一些基本的样式功能(边框、边距等)。一般来说,它看起来“足够好”。只有一个问题——当鼠标指针悬停在控件上时,它会变得有光泽。这不像我的其他控件的行为 - 有没有一种简单的方法可以消除这种效果?
我尝试过使用触发器:
<Style>
...
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red" />
<Setter Property="Border.BorderBrush" Value="Black" />
...
</Style.Triggers>
</Style>
但这并没有起到多大作用。我也尝试过设置IncreaseButtonContentTemplate 字段,但结果也不好。
【问题讨论】:
-
试试
<Setter Property="OverridesDefaultStyle" Value="true"/>
标签: wpf xaml telerik numericupdown wpf-style