Thursday, December 27, 2018

WPF 问题记录之 DataGridCell 的 TextBlock.Padding 属性不生效


修改 DataGridCell 的 TextBlock.Padding 属性或者 Padding 属性不生效


方案1,修改ControlTemplate
参考:
https://stackoverflow.com/questions/5246745/set-a-padding-on-datagridcells-in-wpf


方案2 ,修改 DataGridTextColumn 的 ElementStyle 属性
参考同一个贴子最上面的楼主回复
1  ok, I accepted your answer though I found an other way (a bit more of a hack, but easier in my case): Set up the margin property on the cell's content by using the ElementStyle property. Your solution is nicer though.
ElementStyle 属性用法参考:
https://blogs.msdn.microsoft.com/vinsibal/2008/08/19/wpf-datagrid-stock-and-template-columns/

No comments:

Post a Comment

华为交换机option43和60实例

AC: Aruba 651- 10.77.25.1 AP: Aruba 105 - 172.17.2.0/24 SW: 华为S5720  ip pool pool2  gateway-list 172.17.2.1  network 172.17.2.0 mask 255.255...