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

How To refuse to drop by decisioning sender.

2 Answers 59 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
B/S.SOFTWARE
Top achievements
Rank 1
B/S.SOFTWARE asked on 20 Mar 2010, 09:01 AM
Hi

<Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.5*"/>
                <ColumnDefinition Width="0.5*"/>
        </Grid.ColumnDefinitions>
        <!-- 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>
        </telerikNavigation:RadTreeView>
        <!-- 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>
        </telerikNavigation:RadTreeView>
</Grid>

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

[Question]
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()
        {
            InitializeComponent();

            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.

regards.

yuh

2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 25 Mar 2010, 03:12 PM
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.
0
B/S.SOFTWARE
Top achievements
Rank 1
answered on 26 Mar 2010, 02:52 AM

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

Yuh

Tags
DragAndDrop
Asked by
B/S.SOFTWARE
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
B/S.SOFTWARE
Top achievements
Rank 1
Share this question
or