There is a WPF Datagrid, with nothing special with it. It has sometimes HeadersVisibility All/Row, depends on the usage in our code. But regardless of the header style, it has alignment issues. Neither the header/data text are aligned properly, nor the first headers in the top-left corner, 1 pixel is missing here. I attach a picture to be more visible.
This really looks unprofessional and amateur. The text align is much worse than the top-left corner, so if I could fix that it would already be a big improvement.
Vertical: as I see, the row header texts are aligned properly to the center, unlike the data which is a bit above.
Horizontal: here does not matter which one is aligned to which (header<>data), but at least they should be in-line.
Thanks
EDIT The XAML part:
<dg2d:DataGrid2DT.CellStyle>
<Style TargetType="wpftoolkit:DataGridCell">
<Setter Property="TextBlock.VerticalAlignment" Value="Stretch"/>
<Setter Property="TextBlock.HorizontalAlignment" Value="Stretch"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="LightBlue"/>
</Trigger>
</Style.Triggers>
</Style>
</dg2d:DataGrid2DT.CellStyle>
I tried to add <Setter Property="TextBlock.Padding" Value="5, 5, 0, 0" />
but this had no effect. Just for try I added <Setter Property="TextBlock.TextAlignment" Value="Right" />
- this works fine. Only paddig does nothing. Maybe cell is too small for padding?
EDIT2
If I set VerticalAlignment to "Center" Textblock is put to the center of the cell. With this the text is more or less in the center, but not good, as textblock is not filling the cell anymore. I want the textblock to fill the cell, and have the text vertically centered. Using "Padding" should solve my problem, but it has no effect.
VerticalAlingment
and/or 'HorizontalAlignment' of the content-control of your rowheader or column-header. You can also try to set them on your Cell – TomtomDataGridTemplateColumn
? – Tomtom