5

I've got 2 buttons on my form, and they both look very, very flat.

Flat Buttons

I can't seem to find a way to make them look more like:

Not Flat Button

The XAML for my buttons is:

<Button x:Name="bttnDailyReport" HorizontalAlignment="Left" Margin="618,27,0,0" VerticalAlignment="Top" Width="121" Height="93" FontFamily="Microsoft Sans Serif" FontSize="20" FontWeight="Bold" Grid.Column="1" BorderBrush="Black">
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"><Run Text="  Generate"/><LineBreak/><Run Text="Daily Report"/></TextBlock>
</Button>
<Button x:Name="bttnCancel" HorizontalAlignment="Left" Margin="618,126,0,0" VerticalAlignment="Top" Width="121" Height="93" FontFamily="Microsoft Sans Serif" FontSize="20" FontWeight="Bold" Click="BttnCancelClick">
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"><Run Text="Exit"/></TextBlock>
</Button>

Now, my question is, is it possible to make the buttons appear like the button in WinForms, or am I stuck with flat buttons?

Tilak
  • 30,108
  • 19
  • 83
  • 131
PiousVenom
  • 6,888
  • 11
  • 47
  • 86

3 Answers3

3

Seems, somewhere in your resources, flat button style is used as default style for button.

Check Styling and Templating. Either you need to override the style in your button, or give key to the default style, and apply wherever needed.

How to override a global style (that doesn't have an x:Key), or alternatively apply a named style to all type-targeted controls?

Community
  • 1
  • 1
Tilak
  • 30,108
  • 19
  • 83
  • 131
  • Finally got around to looking around those links. Took me a bit to get through them, but I figured out how to do what I wanted. Thank you. – PiousVenom Dec 19 '12 at 21:58
2

Just reference PresentationFramework.Aero.dll in your project and add this code to to the window's XAML:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/aero.normalcolor.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
Dmitry Arestov
  • 1,427
  • 12
  • 24
  • FYI, You need to copy the DLL locally (add reference, right click in Solution Explorer, Properties, CopyLocal to true), and then you get the catskins for nothing. Also, you can add to ApplicationResources if you want this for all windows. This is the least time, most gain answer. Ref: http://stackoverflow.com/questions/33386220/how-to-add-presentationframework-aero-theme-to-resourcedictionary – Steve Hibbert Apr 12 '17 at 14:48
0

By default, buttons should look like the second image. To make sure that there is no "BoringButton" Style around that make your buttons look flat (as Tilak and Chris W suggest), try to explicitly clear your button's Style like this:

<Button x:Name="bttnDailyReport" Style="{x:Null}" >

Also, don't set your button's Background to a specific color (although that already looks OK in the code you posted).

Sphinxxx
  • 12,484
  • 4
  • 54
  • 84
  • In WinForms, yes, they do look like that. But not in WPF. – PiousVenom Dec 19 '12 at 20:50
  • @TyrionLannister - In all WPF (not WinForms) projects I have made, buttons look similar to your "Connect" button by default. Try to create a new "WPF Application" in Visual Studio and put a button on the MainWindow. Does it still look flat? – Sphinxxx Dec 19 '12 at 21:26
  • I've done just that, and yes, its flat. I've done this in both VS2010 and VS2012, with .NET 4 and 4.5. – PiousVenom Dec 19 '12 at 21:41
  • 2
    @TyrionLannister - Ok. In that case I don't know what's wrong. At work I have used both VS2010 and VS2012 (.Net 3.5 and 4.0), and at home I use VS2010 Express (3.5 and 4.0), and all buttons are proper-looking by default. If all else fails, creating your own ControlTemplate (see Cris W's link) should work. – Sphinxxx Dec 19 '12 at 22:39