Search code examples
c#datagriddatagridcolumnheader

How to change the orientation of a DataGrid's column header in C#?


I defined a DataGrid in my WPF and I want to make some column headers appear in vertical form. In this other post, this is done via MVVM. But how can I do this in C# code?

In other words, the method that used MVVM changes the orientation of all column headers. But I want some of headers to be vertical.


Solution

  • I kinda asked this question again in here (in another form though). The accepted answer solved my problem. I advise the future readers with the same issues to refer to that post. In summary, you have to define multiple styles for the DataGridColumnHeader and also assign an event handler to the AutoGeneratingColumn event. And then, apply the desired style programmatically.

    It seems abiding to the MVVM pattern is an overkill.