我希望我能用我的自定义版本MyDataGridRow替换DataGrid中的标准DataGridRow。
public class MyDataGridRow : DataGridRow
{ ... }我知道我可以替换标准DataGridRow的Template,但我想完全替换它,因为它打开了大量的选项,比如引入新的属性、事件等。
我认为这应该是可能的。
你的想法!
与可能的副本相比,这个问题更清楚:How can I add Dependency Property to a DataGridRow WPF。我的问题标题和问题内容更有帮助,也更通用。就像之前发布这个问题一样,我搜索了很多,但什么也找不到。
发布于 2016-07-27 17:01:27
创建一个新的DataGrid并覆盖其GetContainerForItemOverride()方法以返回新的DataGridRowEx。
public class DataGridRowEx : DataGridRow
{
// you can add any custom dependency property here
}
public class DataGridEx : DataGrid
{
//...
protected override DependencyObject GetContainerForItemOverride()
{
return new DataGridRowEx();
}
}https://stackoverflow.com/questions/38607531
复制相似问题