Can we change the drag/drop tooltip when e.QueryResult = true

6 posts, 0 answers
  1. James
    James avatar
    26 posts
    Member since:
    Oct 2008

    Posted 05 Apr 2012 Link to this post

    Hi,

    Im trying to change the drag/drop tooltip and I followed this post: http://www.telerik.com/help/silverlight/radtreeview-how-to-set-drag-cue-feedback-deny-drop.html

    Our scenario is allow client to drop item before/after another item but we need to change the tooltip message, so my code is:private void OnDropQuery( object sender, DragDropQueryEventArgs e )
    {
        var destination = e.Options.Destination as RadTreeViewItem;
        var cue = e.Options.DragCue as TreeViewDragCue;
        // Do not allow dropping inside items which start with "B", only handle cases
        // where a drop is currently allowed.
        if ( destination != null
            && e.Options.Status == DragStatus.DropDestinationQuery
            && e.QueryResult == true
            && destination.DropPosition == DropPosition.Before
            && ( destination.Item as MyViewModel ).Title.StartsWith( "B" ) )
        {
            // Debying a drop will set the cue.IsDropPossible = false
            e.QueryResult = true;
            // We only need to give a reason:
            cue.DragActionContent = "Can drop before Bs, hahaha";
        }
    }

    Howevere, it never worked when e.QueryResult = true.  Could you guys help me with this one, please?  Doe it work in your end or there is something at my end is wrong?


    Regards

    Bill

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Apr 2012 Link to this post

    Hi James,

     When setting e.QueryResult = true in Drop Query then you need to use the DropInfo event with DragStatus = DropPossible in order to set the DragActionContent:

    // OnDropInfo event handler
            private void OnDropInfo(object sender, DragDropEventArgs e)
            {
                if (e.Options.Status == DragStatus.DropPossible)
                {
                    (e.Options.DragCue as TreeViewDragCue).DragActionContent = "POSSIBLE DROP ";
                }
            }
    You can find this realized in the attached example. Please give it a try and let us know if it satisfies you.

    Kind regards,
    Petar Mladenov
    the Telerik team

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

  3. DevCraft banner
  4. James
    James avatar
    26 posts
    Member since:
    Oct 2008

    Posted 10 Apr 2012 Link to this post

    Thanks Petar!  Our issue is resolved.

    One more question: I found that we can only update the prefix of the tooltip message. For example,  in "drop before aaa", only the "drop before" can be updated, the header of the treeview item will always get into the tooltip.  Is there any way to change the whole tooltip message?


    Regards

    Bill
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 13 Apr 2012 Link to this post

    Hello James,

     Yes, this is possible. Please check out the following code and its comments:

    // OnDropInfo event handler
            private void OnDropInfo(object sender, DragDropEventArgs e)
            {
                if (e.Options.Status == DragStatus.DropPossible)
                {
                    (e.Options.DragCue as TreeViewDragCue).DragActionContent = "ACTION :";
     
                    //// DragTooltipContent properties are responsible to represent the second part of the informative text in the drag cue.
                    //// The object placed in the content will be show using the template.
                    //// The template should be set to null or other template. By default it is the same as the header template of the item.
                    (e.Options.DragCue as TreeViewDragCue).DragTooltipContentTemplate = null;
                    (e.Options.DragCue as TreeViewDragCue).DragTooltipContent = ": CONTENT";
                }
            }
    All the best,
    Petar Mladenov
    the Telerik team

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

  6. Miroslav
    Miroslav avatar
    5 posts
    Member since:
    May 2012

    Posted 11 May 2012 Link to this post

    I am wondering can we remove the tooltip template  with the arrow and replace it with our custom template.And remove the cue.ItemTemplate.The desired effect is in the attached picture.
  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 May 2012 Link to this post

    Hi Miroslav,

     The attached example shows how you can define a custom DracCueTemplate. Please let us know if this helps you or not.

    Regards,
    Petar Mladenov
    the Telerik team

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

Back to Top
DevCraft banner