I am working on a WPF application where I'm trying to define different common styles to be used throughout the application. I'm quite new in this area, so I don't know whether there is something I've misunderstood. Anyway, here it goes:
As an example, I have created a Resource Dictionary with different common formattings. One of these is a format for a Border. The definition goes like this:
<Style x:Key="MainBorderStyle" TargetType="{x:Type Border}">
<Setter Property="IsEnabled"
Value="True" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Gold" />
<Setter Property="CornerRadius"
Value="6" />
<Setter Property="BorderThickness"
Value="2" />
<Setter Property="Padding"
Value="2" />
</Style>
Now, I want to use this formatting throughout the application by different elements - buttons, rectangles, group boxes, etc.
At the moment I have troubles applying the border format to GroupBox controls. I also have a predefined format for GroupBox controls.
In several places in the XAML code, I have had luck applying a reference to the Border setting above, by using the code snippet
<Border Style="{StaticResource MainBorderStyle}" x:Key="SomeKeyID" />
However, for GroupBoxes for example, I can't make this working, and I have to provide all the formatting for the brushes, corners, etc. repeatedly within each groupbox.
What can the problem be? Any suggestions will be highly appreciated.
Best regards.