Reputation: 329
I have the following style that hides or makes invisible at the border of a button:
<Style x:Key="SinBorde" 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 looks like the one on the left of the next image, notice the button on the right that doesn't have that style applied and the text is in the middle of the button:
Any comments or suggestions how to center text are welcome
Upvotes: 0
Views: 30
Reputation: 35681
default Button template sets alignment for content:
<Style x:Key="SinBorde" TargetType="{x:Type Button}" >
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="Transparent">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Upvotes: 1