tags:

views:

47

answers:

2

So that when I apply additional typed styles in my application I don't have to do the BasedOn thing in order for them to be merged with my custom global style. You know, like happens with Microsoft's own styles. Essentially, I want to apply my style at number 9 instead of 8.

If that's relevant: I also want to completely ignore themes and anything else that might make my application appear differently on different machines.

Edit: I want to do this for controls that I didn't make, like, Button.

A: 

It sounds like what you want to do is create a different Generic.xaml (theme) Style for a control but that isn't something that's intended for built-in controls. You might be able to do something like create an alternate theme assembly with your Styles that you can fool WPF into loading (i.e. PresentationFramework.Aero.dll) or subclassing controls you want to replace templates on. Before going down that road you should really evaluate whether it's worth the time investment. Anything you might be able to get to work is going to add complexity and be a lot of extra work just to change your local default Style declarations from

<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">

to

<Style TargetType="{x:Type Button}">

As far as ignoring themes, there's not much you can control as far as the automatic selection process. The standard way to do it is to copy the default Style from a specific theme into your App.xaml as your application default Style and modify as necessary but that obviously creates the situation that you're trying to get away from.

John Bowen
A: 

If you set the OverridesDefaultStyle property to true in your custom Style, then the theme Styles (or default Styles) will be ignored. This effeictvely makes your Style the only Style used.

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.overridesdefaultstyle.aspx

Tom Goff