drag/drop question

3 posts, 1 answers
  1. joost
    joost avatar
    2 posts
    Member since:
    Mar 2011

    Posted 04 Apr 2011 Link to this post

    Dear,

    After experimenting some time with the rad controls I find them quite cool and capable of doing a lot of work for me. Thank you for creating this handy suite!

    Nevertheless I found some difficulty in implementing my specific drag/drop scenario. I've attached my demo project. It consists of three UI components.

    rad_wpf_demo1.zip

    RadTreeview, green (tvA)
    RadTreeListView, white (tlv)
    RadTreeview, pink (tvB)

    The goal is to edit the data in the tlv by just dragging/dropping from both treeviews.
    The left treeview (tvA) is used for making structural changes to the treelistview by adding nodes to the tree.
    The right treeview (tvB) is used for changing values to the treelistview by changing properties.

    Question 1:
    When items from tvB are dragged over tvB or tvA, the row highlights.
    There is no row-highlighting when dragged over the treelistview. How can this be enabled ?

    Question 2:
    It is a requirement that items dragged from tvB (pink) can only be dropped ON a row in the tlv, and not in between.
    Nodes dragged from tvA can be dropped before, on and after a row.
    How can it be achieved to 'disable' the drop-preview-line for a single drag-source, whilst being enabled when dragging from another source ?

    Question 3:
    Items dragged from tvB (pink) are only allowed to be dropped on certain rows in the tlv. (Currently implemented as a bool property 'CanDrop'.)
    How can it be achieved (visually) in the tooltip/dragqueue that dropping is (not)allowed based on data in the row ?

    Thank you in advance,

    -Joost
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Apr 2011 Link to this post

    Hi joost,

    You have prepared your example very well and your code needs just a little changes to achieve your specific drag/drop scenario (only the highlighting is a bit complicated)!
    1. Highlighting:
    There is not a property that enables highlighting when a dragged item has been hovered over the row. That is why I will suggest you to define a style for TreeListViewRow and add a trigger to custom created attached property. You should:

    • Add new class MouseOverAdornerBehavior to your project, representing the new property
    • Create new template for TreeListViewRow style with Expression Blend
    • In XAML add the namespace xmlns:local="clr-namespace:demo1"
    • In the Triggers section of the "TreeListViewRowStyle1" add:
    <TriggerProperty="local:MouseOverAdornerBehavior.IsDragOver"Value="True">
                <SetterProperty="Visibility"TargetName="Background_Over"Value="Visible"/>
    </Trigger>

    • Apply the style to the TreeListView
    • In the .cs you need to highlight the row on tlvDataOnDropQuery, and to cancel the highlight when the Drop is not possible (inside tlvDataOnDropInfo and tlvDataOnDropQuery)

    2. How can it be achieved to 'disable' the drop-preview-line for a single drag-source, whilst being enabled when dragging from another source ?

    privatevoidtlvDataOnDropQuery(objectsender, DragDropQueryEventArgs e)
     {...
               TreeListViewDropPosition dropPosition = TreeListViewDropPosition.Before;
                if(row != null)
                {
                    dropPosition = (TreeListViewDropPosition)row.GetValue(RadTreeListView.DropPositionProperty);
                    MouseOverAdornerBehavior.SetIsDragOver(row, true);
                }
    ...
               if(e.Options.Source != null&&
                    e.Options.Source.ParentOfType<RadTreeView>() == this.rtvValues &&
                    dropPosition != TreeListViewDropPosition.Inside)
                {
                    e.QueryResult = false;
                }
    ...}

    3. How can it be achieved (visually) in the tooltip/dragqueue that dropping is (not)allowed based on data in the row ?

    You have done it! But you need to handle the handled events for tlvDataOnDropQuery too:

    tlvData.AddHandler(RadDragAndDropManager.DropQueryEvent, newEventHandler<DragDropQueryEventArgs>(tlvDataOnDropQuery), true);

    You may find a sample project attached. 
    If you have any other questions regarding this, please do not hesitate to contact us!

     Greetings,
    Maya
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. joost
    joost avatar
    2 posts
    Member since:
    Mar 2011

    Posted 07 Apr 2011 Link to this post

    Thank you very much!

    This reply is very helpful, it allows me to take a big step forward and it also shows the very good support Telerik is providing.

    have a nice day!

    -Joost
Back to Top