简体   繁体   中英

Styling Telerik WPF NumericUpDown Control

I use Telerik WPF controls and need to add a NumericUpDown control to my UI. 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:

<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:

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

You need to modify the default ControlTemplates and remove any "shiny and glossy" effects from them. 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.

There is no "DisableEffects" property that you can simply set on the control I am afraid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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