如何将列标题对齐到DataGrid的中心 [英] How to align the column header to center in DataGrid

查看:123
本文介绍了如何将列标题对齐到DataGrid的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对齐DataGrid的Column标头使其在WPF的DataGrid中居中.我更喜欢使用XAML
进行设置
在此先感谢

Iqbal

How I can align the Column header of DataGrid to center in DataGrid of WPF. I prefer to set it using XAML

thanks in advance

Iqbal

推荐答案

此块可能对您有帮助:

< pre lang ="HTML">
...
< DataGridTextColumn Header ="Nombre"
Binding ="{Binding Nombre}">
< DataGridTextColumn.HeaderStyle>
< Style TargetType ="DataGridColumnHeader">
< Setter Property ="Horizo​​ntalContentAlignment"
Value ="Center"/>
</Style>
</DataGridTextColumn.HeaderStyle>
...
</pre>
This block might help you:

<pre lang="HTML">
...
<DataGridTextColumn Header="Nombre"
Binding="{Binding Nombre}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment"
Value="Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
...
</pre>


这篇关于如何将列标题对齐到DataGrid的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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