How to Release Mouse whilst Dragging

4 posts, 0 answers
  1. Paul
    Paul avatar
    12 posts
    Member since:
    Jun 2009

    Posted 11 Feb 2011 Link to this post

    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
  2. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 16 Feb 2011 Link to this post

    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>>
  3. DevCraft banner
  4. Paul
    Paul avatar
    12 posts
    Member since:
    Jun 2009

    Posted 16 Feb 2011 Link to this post

  5. Paul
    Paul avatar
    12 posts
    Member since:
    Jun 2009

    Posted 16 Feb 2011 Link to this post

    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
Back to Top