简体   繁体   English

设置Telerik WPF NumericUpDown控件的样式

[英]Styling Telerik WPF NumericUpDown Control

I use Telerik WPF controls and need to add a NumericUpDown control to my UI. 我使用Telerik WPF控件,并且需要在UI中添加NumericUpDown控件。 The thing is when used "as it is" it doesn't fit the rest of the application visually 问题是,按原样使用时,它在视觉上不适合应用程序的其余部分

<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. </>

I added the control to my UI: 我将控件添加到我的UI:

<telerik:RadNumericUpDown
  Minimum="0"
  Maximum="10"
  SmallChange="1"
  NumberDecimalDigits="0"
  IsInteger="True"
  Value="{Binding Path=Counter}" />

Also, I've added some styling to a ResourceDictionary: 另外,我在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>

And this handles some basic styling features (border, margin, etc). 这可以处理一些基本的样式功能(边框,边距等)。 In general it looks "good enough". 一般来说,它看起来“足够好”。 There's only one problem - when a mouse pointer hovers over the control, it becomes shiny and glossy. 仅有一个问题-当鼠标指针悬停在控件上时,它将变得有光泽和光泽。 That's not like my other controls behave - is there an easy way to remove this effect ? 那与我的其他控件的行为不同-是否有一种简单的方法可以消除这种影响?

I've tried experimenting with Triggers: 我尝试过使用触发器:

<Style>
...
  <Style.Triggers>
    <Trigger Property="IsMouseOver" Value="True">
      <Setter Property="Foreground" Value="Red" />
      <Setter Property="Border.BorderBrush" Value="Black" />
      ...
  </Style.Triggers>
</Style>

But this didn't do much. 但这并没有太大作用。 I've also tried setting IncreaseButtonContentTemplate field, but this turned out no good either. 我也尝试过设置IncreaseButtonContentTemplate字段,但是结果也不是很好。

You need to modify the default ControlTemplates and remove any "shiny and glossy" effects from them. 您需要修改默认的ControlTemplates并从中删除任何“光泽和光泽”效果。 The easiest way to do this would be to copy the default templates from the Themes.Implicit folder in your Telerik installation directory into your solution and then edit them as per your requirements. 最简单的方法是将默认模板从Telerik安装目录中的Themes.Implicit文件夹复制到解决方案中,然后根据需要进行编辑。

There is no "DisableEffects" property that you can simply set on the control I am afraid. 恐怕您没有可以简单地在控件上设置的“ DisableEffects”属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM