[英]Null values for integers are not displayed properly by the Telerik NumericUpDown control
[英]Styling Telerik WPF NumericUpDown Control
我使用Telerik WPF控件,並且需要在UI中添加NumericUpDown控件。 問題是,按原樣使用時,它在視覺上不適合應用程序的其余部分
<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字段,但是結果也不是很好。
您需要修改默認的ControlTemplates
並從中刪除任何“光澤和光澤”效果。 最簡單的方法是將默認模板從Telerik安裝目錄中的Themes.Implicit
文件夾復制到解決方案中,然后根據需要進行編輯。
恐怕您沒有可以簡單地在控件上設置的“ DisableEffects”屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.