Modify DragCue.DragActionContent when using IsDragDropEnabled

4 posts, 0 answers
  1. Justin
    Justin avatar
    5 posts
    Member since:
    Jun 2011

    Posted 15 Aug 2011 Link to this post

    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
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Aug 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Justin
    Justin avatar
    6 posts
    Member since:
    May 2011

    Posted 07 Sep 2011 Link to this post

    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)
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 13 Sep 2011 Link to this post

    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 >>

Back to Top