views:

38

answers:

1

I want to make 2 different styles for the ToolBar control: One is based on black buttons and one on silver buttons. But I can't figure out how to apply my button styles to its own toolbar styles. The following only allows one style for the buttons:

 <Style x:Key="{x:Static ToolBar.ButtonStyleKey}" 
        BasedOn="{StaticResource BlackButtonStyle}"
        TargetType="{x:Type Button}"/>
A: 

Not sure if this will work or not... I'm assuming you only want one style at a time (if you had two tool bars and wanted each to be different you need two different styles with two different keys)...

that said, when you want to change the style from black to silver, can you get get your resource in code, and set the BasedOn property of that style to your SilverButtonStyle resource?

Scott
There are two toolbars co-existing in the same screen, with black on the top and silver on the bottom. The {x:Static ToolBar.ButtonStyleKey} only allows one style for the button at a time. For now, I simply substitute stackpanel for one of the toolbars...
mobileTofu
Ahhh... I see the problem better now. Not certain this will work... but each toolbar has it's own .Resources section... can you put your style you listed above into each of the toolbar's resource section (and for the one you want to be silver modify the BasedOn to use the SilverButtonStyle)?Just a thought but maybe you've already tried that.
Scott