Reputation: 9827
I wish I could replace standard DataGridRow
in a DataGrid
with my custom version : MyDataGridRow
.
public class MyDataGridRow : DataGridRow
{ ... }
I know I can replace the Template
of standard DataGridRow
, but I want to replace it entirely, as it opens plenty of options like introduction of new properties, events etc.
It should be possible, I think.
Your thoughts !
The question is more clear in comparison to possible duplicate : How can I add Dependency Property to a DataGridRow WPF . My question title and question content is more helpful and more general. As before posting this question I searched a lot but couldnt find anything.
Upvotes: 0
Views: 385
Reputation: 9827
Create a new DataGrid
and override its GetContainerForItemOverride()
method to return the new DataGridRowEx
.
public class DataGridRowEx : DataGridRow
{
// you can add any custom dependency property here
}
public class DataGridEx : DataGrid
{
//...
protected override DependencyObject GetContainerForItemOverride()
{
return new DataGridRowEx();
}
}
Answer adapted from How can I add Dependency Property to a DataGridRow WPF
Upvotes: 1