I created a DataTemplate from a Button and put the MinWidth
and MinHeight
to 0
. I set the width and height to 75 on the Grid of the DataTemplate. The grid has a border and it's MinWidth and MinHeight are also both set to 0
. The width and height of the border is set to auto(75
).
Now when I put the button on my page it's width is 109.166664123535
and height is 75. When viewing the DataTemplate in Blend it says the Grid and it's children are width of 75 but the DataTemplate itself wider.
How do I make the entire DataTemplate a width
of 75
and not just the DataTemplate children?
Edit 1 After @Guttsy suggestions, this is what I changed the code to look like. Also note NumberPadButtonStyle removes the top and bottom padding on the buttons ControlTemplate border. The code is below:
<Grid HorizontalAlignment="Center" VerticalAlignment="Top">
<Grid.Resources>
<Style x:Key="SetDominationsNumberPadButtonStyle"
BasedOn="{StaticResource NumberPadButtonStyle}"
TargetType="Button">
<Setter Property="Width" Value="110" />
<Setter Property="Height" Value="110" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Content="1" Style="{StaticResource SetDominationsNumberPadButtonStyle}" />
<Button Grid.Column="1"
Content="2"
Style="{StaticResource SetDominationsNumberPadButtonStyle}" />
<Button Grid.Column="2"
Content="3"
Style="{StaticResource SetDominationsNumberPadButtonStyle}" />
<Button Grid.Row="1"
Grid.Column="0"
Content="5"
Style="{StaticResource SetDominationsNumberPadButtonStyle}" />
<Button Grid.Row="1"
Grid.Column="1"
Content="6"
Style="{StaticResource SetDominationsNumberPadButtonStyle}" />
<Button Grid.Row="1"
Grid.Column="2"
Content="7"
Style="{StaticResource SetDominationsNumberPadButtonStyle}" />
</Grid>