This is a migrated thread and some comments may be shown as answers.

Modify DragCue.DragActionContent when using IsDragDropEnabled

3 Answers 80 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 16 Aug 2011, 01:29 AM
Hi,

I am using a RadTreeView setting the IsDragDropEnabled to true, instead of RadDragAndDropManager.AllowDrag.

My goal is to change the DragCue.DragActionContent to "Copy to" when the user presses the Control key.

_treeView.AddHandler(RadDragAndDropManager.DropQueryEvent,
                    new EventHandler<DragDropQueryEventArgs>(MainTree_DropQuery), true);
 
private void MainTree_DropQuery(object sender, DragDropQueryEventArgs e)
{
     if (Keyboard.Modifiers == ModifierKeys.Control)
     {
         TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
 
         cue.DragActionContent = "Copy To";
     }
e.QueryResult = true;
}

The DragActionContent property seems to return the current content but changes are not registered unless property is initially null.

Is this the proper method to alter the DragCue when using IsDragDropEnabled?

Thank you,
Justin

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Aug 2011, 04:03 PM
Hello Justin,

 Yes, you can use the DropInfo event of the RadDragAndDropManager:

public MainWindow()
       {
           InitializeComponent();
           treeView.AddHandler(RadDragAndDropManager.DropInfoEvent, new EventHandler<DragDropEventArgs>(OnDropInfo));
       }
 
        
 
       // OnDropInfo event handler
       private void OnDropInfo(object sender, DragDropEventArgs e)
       {
           if (Keyboard.Modifiers == ModifierKeys.Control)
           {
               TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue;
               cue.DragActionContent = "Copy To";
            }           
       }
Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Justin
Top achievements
Rank 1
answered on 07 Sep 2011, 09:02 PM
Hi Petar,

Ive implemented the method you described below.  The difficulty I am having is with the following sequence.

1. User drags item, presses and holds Ctrl.

2. While holding Ctrl, user drags the cue outside of the treeview's logical scope.

3.  When the user releases the control key the "Copy To" text remains on the cue.

Is there any way to do this using an internal event of the DragCue and if so would that be the solution I am looking for?

I am having a few little issues along these lines (Action Content not changing back), just wondering if this is the correct approach.

Thanks Petar,

Justin
(Same person who started the thread, just realized I was using a forum account that I signed up for when I was still in the trial phase)
0
Petar Mladenov
Telerik team
answered on 13 Sep 2011, 09:28 AM
Hi Justin,

 I reproduced your issue in my project and I think the correct approŠ°ch to handle it is to check whether the Drop is Impossible. If the DropIsImpossible, there is no need of setting a DragActionContent. Please check out the attached project and let us know if it works for you. You can also elaborate more on your other issues and we will assist you on them.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
Justin
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Justin
Top achievements
Rank 1
Share this question
or