Reputation: 2764
I'm having issues finding out why my padding is not being respected on the button when applying a style (with no padding attribtues).
<Style x:Key="NoHoverDisabledButton" TargetType="{x:Type Button}">
<Setter Property="Background" Value="#ccc"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Button Style="{StaticResource ResourceKey=NoHoverDisabledButton}" Padding="20,0" x:Name="OnlineUpdateButton" Width="Auto" HorizontalAlignment="Right" BorderThickness="0" Height="32" VerticalAlignment="Top" FontSize="14">
<StackPanel Orientation="Horizontal">
...
</StackPanel>
</Button>
What am I missing here?
Upvotes: 4
Views: 3206
Reputation: 128061
The Padding
property of a control is typically meant to represent an "inner margin", i.e. be assigned to the Margin
property of an element in the ControlTemplate:
<ControlTemplate TargetType="Button">
<Border ...>
<ContentPresenter Margin="{TemplateBinding Padding}" .../>
</Border>
</ControlTemplate>
Upvotes: 11