如何在 WPF DataGrid 的列标题中设置竖排文本? [英] How to set vertical text in the column headers of WPF DataGrid?
本文介绍了如何在 WPF DataGrid 的列标题中设置竖排文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗯,实际上我的意思是从水平方向旋转 -90 度.
Well, actually rotated -90 degrees from horizontal is what I mean.
我需要这样做是因为标题的文本很长但单元格值很短,而且我想在屏幕上显示很多列.
I need to do this because the text for the header is quite long but the cell value is short, and I want to fit a lot of columns on the screen.
是否可以轻松完成此操作,还是我需要先了解资源和模板?我不介意黑客"解决方案!
Is it possible to do this easily or do I need to learn about resources and templates first? I don't mind a "hack" solution!
推荐答案
这将旋转整个 ColumnHeaderCell:
This will rotate the whole ColumnHeaderCell:
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="270" />
</Setter.Value>
</Setter>
</Style>
</DataGrid.ColumnHeaderStyle>
注意:这意味着 HorizontalContentAlignment
然后是 VerticalContentAlignment
,反之亦然.
Be aware: this means HorizontalContentAlignment
is then a VerticalContentAlignment
and vice versa.
这篇关于如何在 WPF DataGrid 的列标题中设置竖排文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文