1 person following this project (follow)

Rotates WPF DataGrid at design-time and run-time

Image of Transposed WPF DataGrid

RotatedDataGrid.jpg

Instructions for using the Transposed WPF DataGrid

Add the following sections to your DataGrid:
            <DataGrid.Resources>
                <Style TargetType="DataGridColumnHeader">
                    <Setter Property="LayoutTransform">
                        <Setter.Value>
                            <TransformGroup>
                                <RotateTransform Angle="-90" />
                                <ScaleTransform ScaleX="1" ScaleY="-1" />
                            </TransformGroup>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
                </Style>
                <Style TargetType="DataGridCell">
                    <Setter Property="LayoutTransform">
                        <Setter.Value>
                            <TransformGroup>
                                <RotateTransform Angle="-90" />
                                <ScaleTransform ScaleX="1" ScaleY="-1" />
                            </TransformGroup>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
                </Style>
            </DataGrid.Resources>
            <DataGrid.LayoutTransform>
                <TransformGroup>
                    <RotateTransform Angle="90" />
                    <MatrixTransform Matrix="-1, 0, 0, 1, 0, 0" />
                </TransformGroup>
            </DataGrid.LayoutTransform>

Note: Some CellStyle choices will prevent the DataGrid from rotating completely, so if your DataGrid does not display as illustrated above, please remove the misbehaving CellStyle settings.

Last edited Feb 2 at 11:31 PM by onejbsmith, version 8