I have the following xaml:
<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True">
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Grid>
<ContentPresenter Height="50">
<ContentPresenter.Resources>
<Style TargetType="TextBlock">
<Setter Property="Padding" Value="4"/>
</Style>
</ContentPresenter.Resources>
</ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.CellStyle>
</DataGrid>
It turns out that the TextBlock has a default padding of 2,0.
Why is the style not applied?
EDIT: I used this solution (from here) that takes the text from the autogenerated TextBlock (Content.Text) and displays it in another TextBlock:
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid SnapsToDevicePixels="True">
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=Content.Text}" Padding="4"/>
</Grid>
</ControlTemplate>