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

How to Release Mouse whilst Dragging

3 Answers 58 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 11 Feb 2011, 03:00 PM
Hello,

I have a RadTreeView and I want to drag an item onto a ContentPresenter which contains a RadHtmlPlaceHolder. I have wrapped the ContentPresenter in a StackPanel, so I have

<StackPanel x:Name="unityBorder" 
        Grid.Column="2" 
        Width="602"
        Height="452"
        telerik:RadDragAndDropManager.AllowDrop="True">
    <ContentPresenter x:Name="myContentPresenter" >
         <telerik:RadHtmlPlaceholder x:Name="myHtmlPlaceholder" .... />
    </ContentPresenter>
</StackPanel>

The stack panel is one pixel wider that the HTML contents. The drag works OK, I can catch the OnDropQuery event as soon as the StackPanel picks it up. As the mouse moves over the HTML, Silverlight is no longer receiving the mouse events (IFrame and all that). What I want to do is simulate a drop in the RadHtmlPlaceHolder by releasing the drag. Otherwise, when the RadHtmlPlaceHolder loses focus, the Silverlight app behind still thinks we have yet to drop the item.

Any ideas?

Cheers,

Paul

3 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 16 Feb 2011, 08:46 AM
Hello Paul,

In this scenario I can suggest the following:

 - Attach to RootVisual.LostFocus and add the following code:
if(RadDragAndDropManager.IsDragging)
{
   RadDragAndDropManager.CancelDrag();
}
In addition there should be some code in the corresponding drag/drop handlers that recognizes this case (the e.Options.Status will be DragStatus.DragCancel and the mouse will be over the Htmlplaceholder)

The drawback with of this approach is that when drag over, user needs to click one more time in the iframe, so that Silverlight host loses focus.

 - Another option is to play with MouseLeave/MouseEnter and call similar logic to one mentioned above. The drawback here will be that since there is no way to determine mouse button state the drag will finish even if the mouse button is not released.

Kind regards,
Tsvyatko
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Paul
Top achievements
Rank 1
answered on 16 Feb 2011, 10:12 AM
0
Paul
Top achievements
Rank 1
answered on 16 Feb 2011, 10:16 AM
Thanks, the important line was

     RadDragAndDrpManager.CancelDrag()

I have inserted this into the OnDropQuery event handler for the control that contains the iFrame. The contents of the iFrame detects when the mouse has entered and draws its own mouse pointer, and the Silverlight mouse pointer, if it is being drawn, is under the iFrame so we don't see it.

Cheers,

Paul
Tags
DragAndDrop
Asked by
Paul
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Paul
Top achievements
Rank 1
Share this question
or