如何使用WPF DataGrid中的自定义DataGridRow替换标准DataGridRow
问题描述:
我希望我可以使用我的自定义版本替换DataGrid
中的标准DataGridRow
。如何使用WPF DataGrid中的自定义DataGridRow替换标准DataGridRow
public class MyDataGridRow : DataGridRow
{ ... }
我知道我可以代替的标准DataGridRow
的Template
,但我希望完全替代它,因为它会打开很多像引进新的属性,事件等
它应该是可能的选择,我认为。
您的想法!
与可能的重复相比,问题更加清晰:How can I add Dependency Property to a DataGridRow WPF。我的问题标题和问题内容更有帮助,更一般。就像之前发布这个问题,我搜索了很多,但无法找到任何东西。
答
创建新的DataGrid
并覆盖其GetContainerForItemOverride()
方法以返回新的DataGridRowEx
。改编自How can I add Dependency Property to a DataGridRow WPF
的可能的复制[我如何添加依赖项属性的DataGridRow WPF(http://*.com/questions/24104080/how-can-i-add-
回答依赖属性到一个-datagridrow-WPF) – ASh