0

I'm trying to create style for button in XAML, here is my code:

<Window.Resources>
  <Style x:Key="buttons"
         TargetType="Control">
    <Setter Property="Background">
      <Setter.Value>
        <LinearGradientBrush>
          <GradientStop Color="GoldenRod"
                        Offset="0" />
          <GradientStop Color="Gold"
                        Offset="0.10" />
          <GradientStop Color="White"
                        Offset="0.45" />
          <GradientStop Color="Gold"
                        Offset="0.9" />
          <GradientStop Color="GoldenRod"
                        Offset="1" />

        </LinearGradientBrush>
      </Setter.Value>
    </Setter>
    <Setter Property="FontFamily"
            Value="Consolas" />
    <Setter Property="FontSize"
            Value="15" />
    <Setter Property="FontWeight"
            Value="Bold" />
    <Setter Property="BorderThickness"
            Value="5" />
    <Setter Property="Padding"
            Value="0,0" />

  </Style>
</Window.Resources>

Everything works fine except BorderThickness property - no matter what value I'm putting there, it doesn't change. I'm wondering what is missing in my code.

Daniel
  • 10,864
  • 22
  • 84
  • 115
Patryk
  • 3,042
  • 11
  • 41
  • 83

1 Answers1

5

Checkout the Button control default template here.

http://msdn.microsoft.com/en-us/library/ms753328%28v=vs.90%29.aspx

If we see BorderThickness property has been set to fixed value 1. Hence no changes are reflected.

You need to create a new ControlTemplate for this purpose.

Viv
  • 17,170
  • 4
  • 51
  • 71
RonakThakkar
  • 903
  • 5
  • 7
  • That is not the default template but an example, also the default template is system dependent. But the fact that the border thickness is hardcoded to 1 also applies to the Aero theme. – H.B. May 20 '13 at 12:20
  • Latest WPF default template location seems to be here. http://msdn.microsoft.com/en-us/library/ms753328%28v=vs.100%29.aspx – RonakThakkar May 20 '13 at 12:27
  • No, the headline also states that those are examples. Follow the `Default WPF Themes` link on [this page](http://msdn.microsoft.com/en-us/library/aa970773.aspx). – H.B. May 20 '13 at 12:31