wpfxamlwpftoolkit

How to customize ButttonSpinner control inside an IntegerUpDown control in Extended WPF Toolkit?


Sorry I'm pretty newbie in WPF styling. I have this ButtonSpinner control and I set its width and height using the appropriate properties:

    <xctk:ButtonSpinner Width="200" SpinnerWidth="100" SpinnerHeight="100">
    </xctk:ButtonSpinner>

ButtonSpinner

And it works as you see the up spinner and down spinner width and height are increased accordingly.

But why I cannot do the same when applying it to the ButtonSpinner inside IntegerUpDown control? (IntegerUpDown theme: https://github.com/xceedsoftware/wpftoolkit/blob/master/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Themes/Generic.xaml) :

<xctk:IntegerUpDown Value="1564" Width="200" Height="100">
        <xctk:IntegerUpDown.Resources>
            <Style TargetType="{x:Type xctk:ButtonSpinner}">
                <Setter Property="SpinnerWidth" Value="100"/>
                <Setter Property="SpinnerHeight" Value="100"/>
            </Style>
        </xctk:IntegerUpDown.Resources>
</xctk:IntegerUpDown>

IntegerUpDown

It still looks the same. Am I missing something?


Solution

  • Whether an implicit Style that you add to the Resources property of a control is applied to a child element of that control depends on how the template for control is defined.

    If the template explicitly sets the Style property of the child control as in the example below, the implicit Style in Resources won't be applied:

    <ControlTemplate TargetType="{x:Type xctk:IntegerUpDown}">
        ...
        <xctk:ButtonSpinner Style="{StaticResource someCustomStyle}" ... />
    

    Also, if the template sets the local value of a dependency property of a child control, you cannot set this property using a Style as the local value takes precedence over a value specified by a Setter of a Style.