How To refuse to drop by decisioning sender.

3 posts, 1 answers
    B/S.SOFTWARE avatar
    10 posts
    Member since:
    Mar 2010

    Posted 20 Mar 2010 Link to this post


    <Grid x:Name="LayoutRoot">
                    <ColumnDefinition Width="0.5*"/>
                    <ColumnDefinition Width="0.5*"/>
            <!-- RadTree A -->
            <telerikNavigation:RadTreeView x:Name="TreeA" Grid.Column="0" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch" IsDragDropEnabled="True">
                    <telerikNavigation:RadTreeViewItem Header="TreeA Item1"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeA Item2"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeA Item3"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeA Item4"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeA Item5"></telerikNavigation:RadTreeViewItem>
            <!-- RadTree B -->
            <telerikNavigation:RadTreeView x:Name="TreeB" Grid.Column="1" HorizontalAlignment="Stretch" Margin="5" VerticalAlignment="Stretch" IsDragDropEnabled="True">
                    <telerikNavigation:RadTreeViewItem Header="TreeB Item1"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeB Item2"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeB Item3"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeB Item4"></telerikNavigation:RadTreeViewItem>
                    <telerikNavigation:RadTreeViewItem Header="TreeB Item5"></telerikNavigation:RadTreeViewItem>

    "TreeA","TreeB", there is 2 RadTreeView.
    They are set IsDragDropEnabled Property True.

    I want refuse RadTreeView Drop into itself.
    I tried to implement in OnDropInfo event.
    (compare source and destination,and more)
    Not yet completed,and I noticed a thing
    e.Handled = false; on OnDropInfo, Event not canceled.


        public partial class MainPage : UserControl
            public MainPage()

                RadDragAndDropManager.AddDropInfoHandler(TreeA, OnDropInfo);
                RadDragAndDropManager.AddDropInfoHandler(TreeB, OnDropInfo);
            private void OnDropInfo(object sender, DragDropEventArgs e)
                if (e.Options.Status == DragStatus.DropComplete)
                    // *1 Something that can be resolved?

                    e.Handled = false;

    I'm sorry for My problem appears to be one of two.

    Is good in any way.
    please help,post your good idea.


  2. Answer
    Tina Stancheva
    Tina Stancheva avatar
    3298 posts

    Posted 25 Mar 2010 Link to this post

    Hello Yuh,

    Please accept my apology for the late response.
    If you want to deny the drop operation inside the same tree, it is best to use the OnDropQuery() event handler and set the e.QueryResult property to False whenever the original and final destination of the drag/drop operation are the same.

    As for the e.Handled property of the OnDropInfo() event handler, when it is set to True the event won't propagate further in the visual tree, so you need to keep that in mind when setting the property to True or False.

    I saw the other question you sent (in the other threads) about the DropPosition property of the RadTreeViewItem, so let me answer it as well.
    If you want to deny a DragAndDrop operation, when the value of the DropPosition property is Inside, you can also do it in the OnDropQuery() event handler after checking that the value of the
    (e.OriginalSource as RadTreeViewItem).DropPosition property is DropPosition.Inside.

    Finally, the OnDropQuery() event handler should look like this:

    private void OnDropQuery(object sender, DragDropQueryEventArgs e)
                var dropPosition = (e.OriginalSource as RadTreeViewItem).DropPosition;

                if ((sender as RadTreeView) != (e.Options.Source as RadTreeViewItem).ParentTreeView &&                      dropPosition != DropPosition.Inside)
                    e.QueryResult = true;
                    e.Handled = true;

                else e.QueryResult = false;

    I prepared an example illustrating how you can implement the described scenario. Please take a look at it and let me know if it helps you or if you need more info.

    All the best,
    Tina Stancheva
    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. DevCraft R3 2016 release webinar banner
    B/S.SOFTWARE avatar
    10 posts
    Member since:
    Mar 2010

    Posted 25 Mar 2010 Link to this post

    Hello, Tina

    Thank you for detailed answer to my questions several times.
    Telerik support is contributing greatly to our decision-UX products
    Drag and drop is a good material to our customers suggestions.

    Yours gratefully!!


Back to Top