The BorderBrush property represents the brush that is used to draw the border. The BorderThickness property represents the thickness of the border.
Try this
<Button BorderThickness="0"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" >...
You may have to change the button template, this will give you a button with no frame what so ever, but also without any press or disabled effect:
<Style x:Key="TransparentStyle" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="Transparent">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And the button:
<Button Style="{StaticResource TransparentStyle}"/>
What you have to do is something like this:
<Button Name="MyFlatImageButton"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
Padding="-4">
<Image Source="MyImage.png"/>
</Button>
Hope this is what you were looking for.
Edit: Sorry, forgot to mention that if you want to see the button-border when you hover over the image, all you have to do is skip the Padding="-4".
I don't know why others haven't pointed out that this question is duplicated with this one with accepted answer.
I quote here the solution: 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>
You can use Hyperlink instead of Button, like this:
<TextBlock>
<Hyperlink TextDecorations="{x:Null}">
<Image Width="16"
Height="16"
Margin="3"
Source="/YourProjectName;component/Images/close-small.png" />
</Hyperlink>
</TextBlock>
You may already know that putting your Button inside of a ToolBar gives you this behavior, but if you want something that will work across ALL current themes with any sort of predictability, you'll need to create a new ControlTemplate.
Prashant's solution does not work with a Button not in a toolbar when the Button has focus. It also doesn't work 100% with the default theme in XP -- you can still see faint gray borders when your container Background is white.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With