I have a custom controls library, in which I defined a control template, that uses some custom styles. My control template is located in the Generic.xaml file, and the styles it uses are also located there, and accessed by the control template with the StaticResource markup extension.
In some cases, when I use this controls library, I want to change some of the styles used template, but I don't know how to do that.
I thought that if I would add to my Window's resource dictionary a style with a name, that is used by the template, my style will "override" the one that is defined in Generic.xaml file, but it didn't work.
What should I do?
views:
207answers:
1
+1
A:
does that work?
<Style TargetType="{x:Type YourCustomControl}"
BasedOn="{StaticResource {x:Type YourCustomControl}}">
<Setter Property="SomeStylePropertyOfYourCustomControl"
Value="{StaticResource SomeStyleYouWantToUseInstead}"/>
</Style>
Botz3000
2009-09-29 10:51:13
The keys of my styles are strings, and not types, since the styles in my template are applied on elements instances in the template.
Andy
2009-09-29 10:55:53
using BasedOn="{StaticResource {x:Type YourCustomControl}}" just means it's based on whatever style is the default for your control. Can you post some examples of your styles?
Botz3000
2009-09-29 10:59:09