在datagrid行标题中对齐内容 [英] Aligning content in datagrid row headers

查看:52
本文介绍了在datagrid行标题中对齐内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我已经成功创建了一个在行标题中具有行号的数据网格.但是,它坚持左对齐行标题内容,我一辈子都无法弄清楚如何让它居中对齐.

I have successfully created a datagrid with rownumbers in the row header. But, it insists on left aligning the row header content and I cannot for the life of me figure out how to tell it to center align it instead.

/Må ns Tå nneryd

/Måns Tånneryd

推荐答案

以下是一个可行的示例:

Here's a sample that may work:

 

<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"> 
       
<DataGridTextColumn.CellStyle> 
               
<Style> 
                       
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/> 
               
</Style> 
       
</DataGridTextColumn.CellStyle> 
</DataGridTextColumn> 

<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"> 
       
<DataGridTextColumn.CellStyle> 
               
<Style> 
                       
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/> 
               
</Style> 
       
</DataGridTextColumn.CellStyle> 
</DataGridTextColumn> 


这篇关于在datagrid行标题中对齐内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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