WPF Button No Border No Background

24,963

Solution 1

Is it maybe the style used for a button in a ToolBar that you're referring to? The ToolBar control overrides the Button style so they appear flat. You can apply that style to a button like this...

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

Solution 2

If you want a button that looks like a TextBlock, you can make a button that is a TextBlock.

<Button Content="I'm a Button; click me">
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <TextBlock Text="{TemplateBinding Content}" />
        </ControlTemplate>
    </Button.Template>
</Button>
Share:
24,963

Related videos on Youtube

paparazzo
Author by

paparazzo

Design, develop and maintain C# WPF and ASP.NET business application with large MSSQL backends. Degree in engineering and got into computing via numerical methods.

Updated on July 09, 2022

Comments

  • paparazzo
    paparazzo almost 2 years

    I just need a button so simple that it looks like a TextBlock. Some time ago I saw an answer on SO to style the button based on a static style for a button in a menu but I cannot find that answer (and I have been searching for an hour). Does anyone know what system style I am referring to and the syntax to apply that style to a button?

  • paparazzo
    paparazzo over 12 years
    Good answer and a better answer for my problem but lanR had the system style I was looking for. +1
  • Jake Berger
    Jake Berger about 12 years
    this method allows one to substitute in a clickable <Image /> (without all the button chrome).
  • Jason Rae
    Jason Rae over 11 years
    You may need to specify the type before Content for this to work. See stackoverflow.com/questions/4572304/wpf-inheriting-from-wind‌​ow
  • Amanduh
    Amanduh over 11 years
    This has the benefit that you don't have to implement styles for when the button is moused-over or pressed
  • Chef Pharaoh
    Chef Pharaoh about 11 years
    I would not consider this metro-style though since you don't get the features of mouseover and such without a lot more pain of manually inserting that code.
  • Chef Pharaoh
    Chef Pharaoh about 11 years
    Awesome, just what I was looking for!!
  • xandermonkey
    xandermonkey over 7 years
    Is there a way to resize the button to the amount of text automatically?