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

一些有用的网站

Windows系统安装界面认不到硬盘,加载RST驱动: https://iknow.lenovo.com.cn/detail/419926.html 纯净版Flash: https://gitlab.com/cleanflash/installer/-/releases    ...