I have defined generic themes (key less, styles based on types), for buttons and text boxes. When I create a button instance in my Window where these resources are merged, the styles are rendered properly. But for the same button hosted within a ToolBar, the styles are not applied; the style reverts back to Windows default. Any idea why?
P.S: If I set the style of the buttons hosted within the ToolBar explicitly, then it works fine, but this is something I do not want to do.
This works:
<ToolBarTray> <ToolBar Band="1" BandIndex="1"> <Button Content="Add" Style="{DynamicResource ResourceKey={x:Type Button}}" /> </ToolBar> </ToolBarTray>
This does not work:
<ToolBarTray> <ToolBar Band="1" BandIndex="1"> <Button Content="Add" /> </ToolBar> </ToolBarTray>
In both the cases, if the button is placed outside the ToolBar, styles are applied properly!