views:

2856

answers:

2

I have just been learning about how styles and control templates in WPF can affect the appearance of buttons,

I'm trying to set the Button's FlatStyle, in the resources I've seen I can't find anything that tells me how I can do this, in Windows Forms this is set through FlatStyle = Flat.

How would one do this in WPF?

A: 

WPF Buttons are drawn by WPF and don't have any relation with the underlying Windows API button that has a FlatStyle property. You should use WPF specific methods to style your button appropriately.

Mehrdad Afshari
+9  A: 

The ToolBar class defines a Style that makes Buttons look flat. An example of using it is:

<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"/>

WPF lets you completely restyle controls to make them look like whatever you want, which is why it doesn't have such a specific FlatStyle property on the Button control.

HTH, Kent

Kent Boogaart
Which is more correct? To create a style for Button that mimics the ToolBar.ButtonStyle, or just use the code you've provided. Thanks Ed
MrEdmundo
Depends on your scenario I think. You can also "derive" a style from the ToolBar Button style by using the Style.BasedOn property.
Kent Boogaart