为什么CellStyle写在资源文件里面没有效果啊? #1370
adriel2012
started this conversation in
General
Replies: 1 comment
-
解决了,代码如下: <Style x:Key="DataGridCellElementStyle" TargetType="TextBlock"> </Style>我在一个没有引用HandyControl的项目中测试之后,发现DataGrid的DataGridTextColumn是TextBlock类型的,所以设置它的HorizontalContentAlignment自然就没有效果了,只能用HorizontalAlignment和VerticalAlignment来设置它的位置。还有,TargetType也要指定成TextBlock,并且要关联到DataGridTextColumn的ElementStyle属性。当然,我发现在使用HandyControl的时候,在窗体里面直接写DataGridCellStyle依然是生效的,是可以使用HorizontalContentAlignment对单元格内容进行居中处理的,只是放在资源字典中就会失去效果,这算不算是HandyControl的一个功能性上的Bug呢? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
这是我按照官方文档设置的DataGrid单元格样式,在开发过程中,我发现这段样式代码只有放在DataGrid所在的窗体里面才能起作用,放在资源字典里就不起作用了,一直都没有查到相关的解决方案。奇怪的是ColumnHeaderStyle放在资源字典里就没问题,有没有大佬能帮帮忙啊,这问题折磨我一天了。
Beta Was this translation helpful? Give feedback.
All reactions