如何在所有列标题上启用文本换行? [英] How do I enable text wrapping on all column headers?

查看:218
本文介绍了如何在所有列标题上启用文本换行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在DataGrid的所有列标题上启用文本换行,而不会禁用其他默认标题功能,例如列大小调整,排序方向指示器等。



有没有办法这样做?

解决方案

或者不要打扰app.xaml文件中的原语,执行以下操作(我的对象):

 < DataGrid Name =WBdataGridAutoGenerateColumns =FalseColumnHeaderHeight =50 > 
< DataGrid.ColumnHeaderStyle>
< Style TargetType =DataGridColumnHeader>
< Setter Property =ContentTemplate>
< Setter.Value>
< DataTemplate>
< TextBlock TextWrapping =WrapText ={Binding}>< / TextBlock>
< / DataTemplate>
< /Setter.Value>
< / Setter>
< / Style>
< /DataGrid.ColumnHeaderStyle>
< DataGrid.Columns> ...


I would like to enable text wrapping on all column headers of my DataGrid, without disabling the other default header functionality, such as column resizing, sort direction indicator, etc.

Is there a way to do this?

解决方案

Or don't bother with the primitives in the app.xaml file and do the following (my objects):

<DataGrid Name="WBdataGrid" AutoGenerateColumns="False" ColumnHeaderHeight="50" >
    <DataGrid.ColumnHeaderStyle>
        <Style TargetType="DataGridColumnHeader">
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock TextWrapping="Wrap" Text="{Binding}"></TextBlock>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </DataGrid.ColumnHeaderStyle>
    <DataGrid.Columns> ...

这篇关于如何在所有列标题上启用文本换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆