Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of button border in WPF?

Tags:

i am trying to get rid of button border and only display text, however a thin line around the text gets displayed even though i set borderThickness to 0 and borderbrush to transparent. alt text

my xaml code for save button:

<Button Content="save" Name="btnSaveEditedText"                  Background="Transparent"                  Foreground="White"                  FontFamily="Tw Cen MT Condensed"                  FontSize="30"                  Margin="-280,0,0,10"                 Width="60"                 BorderBrush="Transparent"                 BorderThickness="0"/> 

Is there anyway i can get rid of the button border?

like image 770
sanjeev40084 Avatar asked May 24 '10 20:05

sanjeev40084


2 Answers

You need to override the ControlTemplate of the Button:

<Button Content="save" Name="btnSaveEditedText"                  Background="Transparent"                  Foreground="White"                  FontFamily="Tw Cen MT Condensed"                  FontSize="30"                  Margin="-280,0,0,10"                 Width="60"                 BorderBrush="Transparent"                 BorderThickness="0">     <Button.Template>         <ControlTemplate TargetType="Button">              <ContentPresenter Content="{TemplateBinding Content}"/>         </ControlTemplate>     </Button.Template> </Button> 
like image 114
bitbonk Avatar answered Sep 30 '22 09:09

bitbonk


The method that I recently found to be most useful for this was to have your button use the style of a toolbars. This will only use the image or text while only showing button borders on mouse over.

<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"         Content="save"         Name="btnSaveEditedText"          Background="Transparent"          Foreground="White"          FontFamily="Tw Cen MT Condensed"          FontSize="30"          Margin="-280,0,0,10"         Width="60"         BorderBrush="Transparent"         BorderThickness="0" /> 
like image 35
Dan Asberry Avatar answered Sep 30 '22 08:09

Dan Asberry