WPF Button No Border No Background
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>
Related videos on Youtube
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, 2022Comments
-
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 over 12 yearsGood answer and a better answer for my problem but lanR had the system style I was looking for. +1
-
Jake Berger about 12 yearsthis method allows one to substitute in a clickable
<Image />
(without all the button chrome). -
Jason Rae over 11 yearsYou may need to specify the type before Content for this to work. See stackoverflow.com/questions/4572304/wpf-inheriting-from-window
-
Amanduh over 11 yearsThis has the benefit that you don't have to implement styles for when the button is moused-over or pressed
-
Chef Pharaoh about 11 yearsI 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 about 11 yearsAwesome, just what I was looking for!!
-
xandermonkey over 7 yearsIs there a way to resize the button to the amount of text automatically?