Hi, I'm trying to drag a radgridview row to a treeview. I had this working with listbox, but now I'm switching out the listbox for radgridview. With the listbox I was using the TreeViewDragCue with the listbox itemtemplate, but I'm not sure how to set the itemtemplate for the cue with the radgridview. I tried creating a DataTemplate class, but the items to not seem to get bound. How can I set the item template in the cue and have it use the row data in the binding to display the cue correctly? This is the code I'm using to set the cue:
public void RadGridView_OnDragQuery(object sender, DragDropQueryEventArgs e)
{
if (e.Options.Status == DragStatus.DragQuery)
{
e.QueryResult = true;
e.Handled = true;
var payload = RadGridView.SelectedItems.Cast<object>().ToList();
e.Options.Payload = payload;
//Here we generate the DragCue. Technically we should generate it in the
//DragInfo event with Status DragInProgress. This way we keep the
//presentation and a possible business logic separate. We can do it in the
//DragQuery event when we are not interested in this separation.
e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
var cue = new TreeViewDragCue();
//Please note that we cannot set *any* source since the items may be
//visual objects which cannot be displayed twice. This method tries to
//find their non-visual believable representations.
cue.SetSafeItemsSource(payload);
cue.DataContext = payload[0];
cue.ItemTemplate = new ElementNodeDragDataTemplate();
cue.IsDropPossible = false;
e.Options.DragCue = cue;
}
if (e.Options.Status == DragStatus.DropSourceQuery)
{
e.QueryResult = true;
e.Handled = true;
}
}
public void RadGridView_OnDragQuery(object sender, DragDropQueryEventArgs e)
{
if (e.Options.Status == DragStatus.DragQuery)
{
e.QueryResult = true;
e.Handled = true;
var payload = RadGridView.SelectedItems.Cast<object>().ToList();
e.Options.Payload = payload;
//Here we generate the DragCue. Technically we should generate it in the
//DragInfo event with Status DragInProgress. This way we keep the
//presentation and a possible business logic separate. We can do it in the
//DragQuery event when we are not interested in this separation.
e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
var cue = new TreeViewDragCue();
//Please note that we cannot set *any* source since the items may be
//visual objects which cannot be displayed twice. This method tries to
//find their non-visual believable representations.
cue.SetSafeItemsSource(payload);
cue.DataContext = payload[0];
cue.ItemTemplate = new ElementNodeDragDataTemplate();
cue.IsDropPossible = false;
e.Options.DragCue = cue;
}
if (e.Options.Status == DragStatus.DropSourceQuery)
{
e.QueryResult = true;
e.Handled = true;
}
}