I want to give a button a flat style programmatically when certain conditions occur.
This question shows how I can set a style to a control programmatically, having already defined it in XAML.
This question shows that a flat button style already exists, so it is not necessary to create one in XAML.
ToolBar.ButtonStyleKey
returns a ResourceKey
, and the corresponding style is not defined in my window (it's in ToolBar). How do I use it in code to set the style programmatically?