Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to edit the background of Up and Down spinners for NumericUpDown control #1741

Open
ihsansfd opened this issue Mar 9, 2023 · 2 comments

Comments

@ihsansfd
Copy link

ihsansfd commented Mar 9, 2023

I think currently there's no easy way to customize the background of up and down buttons inside the NumericUpDown control? Even if I redefine the ControlTemplate, the background still cannot be edited from ButtonSpinner as the attribute for editing it doesn't exist.

numericupdown

@XceedBoucherS
Copy link
Collaborator

Hi, You must redefine the SpinnerButtonStyleKey. Here's an example:

xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes;assembly=Xceed.Wpf.Toolkit"

<Window.Resources> <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type themes:ResourceKeys}, ResourceId=SpinnerButtonStyleKey}" TargetType="RepeatButton"> <Setter Property="Background" Value="Orange" /> <Setter Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalOuterBorderKey}}" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Padding" Value="2,2" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type RepeatButton}"> <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true"> <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Background" TargetName="border" Value="Red" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources>

Thank you

@ihsansfd
Copy link
Author

ihsansfd commented Mar 9, 2023

It throws "Assembly "Xceed.Wpf.Toolkit" wasn't found" when I added the namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants