I have a BaseSkin and multiple UserSkins in a separate dll from my WPF application.
Depending on who is using the application, the base skin and one of the user skins will be merged into a resource dictionary and loaded for the application to use.
What I'm aiming for is the ability to specify a style in a BaseSkin file, and then on a specific UserSkin file be able to override it, changing any properties I need to.
I know I can accomplish this by using the BasedOn attribute like this:
Base:
<Style x:Key="ButtonBg" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Green"/>
</Style>
User:
<Style x:Key="CustomButtonBg" TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonBg}">
<Setter Property="Background" Value="Blue"/>
</Style>
The problem is that now the elements have to have a Style of CustomButtonBg which may not actually be implemented. Is there any way to have both styles use the same key (ButtonBg), and when they're merged have the application look for a style named ButtonBg in User first, and if one doesn't exist, use the one in base?
I was thinking that if I could give the assembly name in the BasedOn attribute to point towards the BaseSkin file, I could avoid naming errors when I give them the same key, but I can't find any way to do that. The other options are to just force an implementation of each style even if nothing gets changed, or check programatically in the skins, but those are last resorts.