WPF DataGrid: Clipping on ColumnHeadersPresenter
-
Hello, I am having some issues with the display of the DataGridColumnHeadersPresenter in my custom DataGrid template. Example Screenshots I have taken the original ControlTemplate for DataGrid and altered the area related to the DataGridColumnHeadersPresenter and the select all Button. What I am experiencing when I load the application (Figure A) is the area taken up by the DataGridColumnHeadersPresenter is longer than it should be (on the right side) by 2 pixels (or whatever the margin is set to). It also appears clipped as it does not show the right side border or the corner radii. When I adjust the size of the window at runtime using the Window 'resizing handles' (Figure B) the appearance changes and the DataGridColumnHeadersPresenter appears as I expect it to. However when I resize it small enough so that the DataGrid's horizontal scroll becomes active (Figure C) it again appears clipped, this time being a few pixels shorter than the expected length. Custom Row, RowHeader, Cell and ColumnHeader styles are also in use, but removing them does not change this problem. Original
<!--Left Column Header Corner -->
<Button Command="{x:Static dg:DataGrid.SelectAllCommand}"
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type dg:DataGrid}}, Path=CellsPanelHorizontalOffset}"
Template="{StaticResource SelectAllButtonTemplate}"
Focusable="false"
Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type dg:DataGrid}},
Path=HeadersVisibility,
Converter={x:Static dg:DataGrid.HeadersVisibilityConverter},
ConverterParameter={x:Static dg:DataGridHeadersVisibility.All}}" />
<!--Column Headers-->
<dgp:DataGridColumnHeadersPresenter Grid.Column="1"
Name="PART_ColumnHeadersPresenter"
Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type dg:DataGrid}},
Path=HeadersVisibility,
Converter={x:Static dg:DataGrid.HeadersVisibilityConverter},
ConverterParameter={x:Static dg:DataGridHeadersVisibility.Column}}"/>My Changes
<tkp:DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"