I would like to have a WPF DataGrid with a horizontal orientation, does anyone know a solution?
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
I've done this earlier since we wanted to be able to use the same control for a
DataGrid
and aPropertyGrid
. Alot of things have to be changed (like alignment, scrolling, positioning of sort-arrows etc.). There is way to much code to post the whole solution but this should get you started. This is an example with Autogenerated TextColumns but you can easily modify it to use other column types.And when the Columns are generated, we reverse their positions and rotates the TextBlocks and TextBoxes (This is better than rotating the
DataGridCell
in terms of alignment, blur etc.)I've simplified a little bit previous solution. I do not like black magic with additional scrollviewer, so I do not use it. But instead I use additional scale transformation.
In case of predefined list of colums it is possible to transfom cells content directly in XAML:
This allows you completely escape codebehind.
I found this approach very useful, I however did a rotation and a mirroring:
or in Xaml:
By using the mirroring I have the field at the end of the column list at the bottom instead of at the top.
I am truly standing on the shoulders of giants here :-) but, I have an additional enhancement.
@dimaKudr suggested a way to transform predefined columns without code behind, and @FrankE refined the order of the columns. What i am adding is a way to transform, automatically generated columns (
AutoGenerateColumns="True"
), by using theDataGrid.CellStyle
template. So the complete (and quite elegant) solution is: