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

Cancel Drag operation on right click

3 Answers 128 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Balaram Barange
Top achievements
Rank 1
Balaram Barange asked on 09 Mar 2010, 10:54 AM
Hi,
I want to cancel drag operation on right click. i dragged item by pressing left click now i press right click(Simultaneously) and want to cancel drag operation.  This is same behavior as window expolere.

Thanks
Bala

3 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 09 Mar 2010, 04:18 PM
Hello Balaram,

You can attach a handler to the window and listen for handled right-click events:

public Window1()
{
    InitializeComponent();
             
    this.AddHandler(FrameworkElement.MouseRightButtonDownEvent, new MouseButtonEventHandler(Window1_MouseRightButtonDown), true);
}

In the Window1_MouseRightButtonDown event handler you can simply cancel the drag:

private void Window1_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
    RadDragAndDropManager.CancelDrag();
}

Please find attached a sample project for further reference. Let me know if you have additional questions on the topic.

Kind regards,
Kiril Stanoev
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
Balaram Barange
Top achievements
Rank 1
answered on 04 Jun 2010, 05:30 AM
Hi Telerik,
Thanks for reply,
I am able to canel drag when i capture right click event of Window.
But I am developing a user control and that user control contain two rad tree which supports drag and drop. This user control is host in several other window.  so I want to capture right click event on user control not on parent window i.e main win. I am attaching you a snap that i captured from snoop utility. Image show the events that has fired when i drag a item and press right click.
There is no event that i can capture from my user control so How can i capture event shown in Images.
 
0
Kiril Stanoev
Telerik team
answered on 08 Jun 2010, 11:55 AM
Hi Balaram,

For this particular scenario you will have to add the MouseRightButtonDownEvent handler to the window that is holding the UserControl (assuming the TreeViews are in this UserControl). In the constructor of the UserControl you can do the following:
 

public TreeViewUserControl()
{
    InitializeComponent();
    Dispatcher.BeginInvoke(new Action(() =>
    {
        var parentWindow = this.ParentOfType<Window>();
        if(parentWindow != null)
        {
            parentWindow.AddHandler(FrameworkElement.MouseRightButtonDownEvent, new MouseButtonEventHandler(TreeViewUserControl_MouseRightButtonDown), true);
        }
        else
        {
            MessageBox.Show("Error! Missing parent window!");
        }
    }), System.Windows.Threading.DispatcherPriority.ApplicationIdle);
}

For further information, please have a look at the attached project. Let me know if you have further questions or comments on the topic.


Best wishes,
Kiril Stanoev
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.
Tags
DragAndDrop
Asked by
Balaram Barange
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Balaram Barange
Top achievements
Rank 1
Share this question
or