I haven't looked at the DataGridDragDropTarget
yet, but couldn't you do just
protected override DataGridRow ContainerFromIndex(DataGrid itemsControl, int index)
{
var row = base.ContainerFromIndex(itemsControl, index);
if (row != null)
{
// do something with row
}
}
?
If that is not implemented for whatever reason, you can try this:
// requires Assembly System.Windows.Controls.Toolkit.dll
using System.Windows.Controls.Primitives;
// ...
protected override DataGridRow ContainerFromIndex(DataGrid itemsControl, int index)
{
var rowsPresenter =
itemsControl.GetVisualDescendants()
.OfType<DataGridRowsPresenter>().FirstOrDefault();
if (rowsPresenter != null)
{
var row = rowsPresenter.Children[index];
// do something with row
}
}
I don't know however how you want to implement the reordering of rows. Chances are you must keep track of your indexes by yourself and return one of your own stored index values in that method.