User (Old forums)MemberMarch 24, 2008 at 8:14 amPost count: 23064
Given a DataGridControl, is there a way to get a reference to its InsertionRow?
Or, given an InsertionRow, I can override EndInit or somesuch to get some code in there, but is there any way to get the DataGridControl it’s being created for?
If it was just created once, I could exploit the timing locality between the creation of the two objects and snag a reference that way, but I’m assuming virtualization means old refs to InsertionRow may become invalid and new ones created at unpredictable times, so I need an on-the-fly solution.
Imported from legacy forums. Posted by Russell (had 5180 views)Xceed SupportMemberMarch 25, 2008 at 8:26 amPost count: 5658
If you want to get a reference to the InsertionRow in the headers of a grid, you will need to handle the InsertionRow’s Loaded event and retrieve the reference there.
To get a reference to an item’s parent DataGridControl, you can either get its DataGridContext and check the ParentDataGridControl property or you can use the GetParentDataGridControl attached property defined on the DataGridControl class.
Imported from legacy forums. Posted by Jenny [Xceed] (had 349 views)User (Old forums)MemberMarch 26, 2008 at 1:22 amPost count: 23064
InsertionRow’s Loaded event – okay, how do you set this? There doesn’t seem to be a Loaded virtual method; one can do row.Loaded += … – but the code to do that, needs to be put somewhere else such as EndInit?
InsertionRow doesn’t seem to have a DataGridContext member?
Imported from legacy forums. Posted by Russell (had 569 views)Xceed SupportMemberMarch 26, 2008 at 9:07 amPost count: 5658
You can do it that way:
<xcdg:InsertionRow Loaded=”MyLoadedHandler” />
Imported from legacy forums. Posted by Marcus [Xceed] (had 572 views)User (Old forums)MemberMarch 26, 2008 at 9:33 amPost count: 23064
Right, that should work for the Loaded handler, thanks – I assume Loaded is called exactly once every time a new InsertionRow is created for a given data grid because of virtualization?
That still leaves the problem of obtaining a handle to the InsertionRow from DataGridControl, or to the DataGridControl from InsertionRow – is there a way to do either of these things? InsertionRow doesn’t have a DataGridContext member, and as far as I can tell from a Google search, ParentDataGridControl is only a property of class Column.
Imported from legacy forums. Posted by Russell (had 1234 views)User (Old forums)MemberMarch 26, 2008 at 12:40 pmPost count: 23064
Further investigation… according to:
Column.ParentDataGridControl no longer exists; the replacement is said to be DataGridControl.GetParentDataGridControl. But how is that a replacement? You can’t call it unless you already have the DataGridControl reference, in which case you don’t need to call it.
Imported from legacy forums. Posted by Russell (had 695 views)Xceed SupportMemberMarch 26, 2008 at 1:55 pmPost count: 5658
It is a static method 🙂
Imported from legacy forums. Posted by Jenny [Xceed] (had 483 views)User (Old forums)MemberMarch 26, 2008 at 7:24 pmPost count: 23064
You’re right, so it is.
void InsertionRow_Loaded(object sender, System.Windows.RoutedEventArgs e)
var grid = DataGridControl.GetParentDataGridControl(sender as DependencyObject);
And then I can store a reference to the InsertionRow in the original DataGridControl. Thanks!
Imported from legacy forums. Posted by Russell (had 6186 views)User (Old forums)MemberJuly 6, 2010 at 11:25 amPost count: 23064
As of version 3.6, GetParentDataGridControl was obsoleted so we now need to use:
var grid = DataGridControl.GetDataGridContext(sender as
Imported from legacy forums. Posted by Jeff (had 1187 views)
- You must be logged in to reply to this topic.