Drag and drop, drag a scatterviewitem and drop to a librarycontainer RRS feed

  • Question

  • Hi, 

    I read your help documents about Dragging and Dropping Items from ScatterView Controls to SurfaceListBox Controls,

    and I got a problem. 

    I use this codes on the documents

    private void DragSourcePreviewInputDeviceDown(object sender, InputEventArgs e)
        FrameworkElement findSource = e.OriginalSource as FrameworkElement;
        ScatterViewItem draggedElement = null;
        // Find the ScatterViewItem object that is being touched.
        while (draggedElement == null && findSource != null)
            if ((draggedElement = findSource as ScatterViewItem) == null)
                findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement;
        if (draggedElement == null)
        DataItem data = draggedElement.Content as DataItem;
        // If the data has not been specified as draggable, 
        // or the ScatterViewItem cannot move, return.
        if (data == null || !data.CanDrag || !draggedElement.CanMove)
        // Set the dragged element. This is needed in case the drag operation is canceled.
        data.DraggedElement = draggedElement;
        // Create the cursor visual.
        ContentControl cursorVisual = new ContentControl()
            Content = draggedElement.DataContext,
            Style = FindResource("CursorStyle") as Style
        // Create a list of input devices, 
        // and add the device passed to this event handler.
        List<InputDevice> devices = new List<InputDevice>();
        // If there are touch devices captured within the element,
        // add them to the list of input devices.
        foreach (InputDevice device in draggedElement.TouchesCapturedWithin)
            if (device != e.Device)
        // Get the drag source object.
        ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement);
        // Start the drag-and-drop operation.
        SurfaceDragCursor cursor =
            // The ScatterView object that the cursor is dragged out from.
            // The ScatterViewItem object that is dragged from the drag source.
            // The visual element of the cursor.
            // The data attached with the cursor.
            // The input devices that start dragging the cursor.
            // The allowed drag-and-drop effects of the operation.
        // If the cursor was created, the drag-and-drop operation was successfully started.
        if (cursor != null)
            // Hide the ScatterViewItem.
            draggedElement.Visibility = Visibility.Hidden;
            // This event has been handled.
            e.Handled = true;

    I run the program and found that I can not zoom the size of scatterviewitem. 

    Although it worked on drop operation, I still want it to have the function of scatterviewitem.

    What should I do?

    Thanks for your help and sorry for my English.

    Tuesday, August 13, 2013 8:18 AM


All replies

  • Check my sample here :




    Your knowledge is enhanced by that of others.

    • Proposed as answer by Serge Calderara Friday, August 16, 2013 10:10 AM
    • Marked as answer by Lemon Trui Wednesday, August 21, 2013 2:34 AM
    Friday, August 16, 2013 10:10 AM
  • Hi, Serge

    Thank you for your help.

    I used your sample(LibraryContainerProject), find that it does works, but I have a little question.

    When I dragged the scatterviewitem to the librarycontainer, it was covered by the librarycontainer, I want it to be the top of librarycontainer, what should I do?


    Tuesday, August 20, 2013 8:32 AM
  • TO set it in front of all visual, you need to set the Zindex property value of the scatterview item.

    For more info:

    Thanks to mark as annswer if it helps


    Your knowledge is enhanced by that of others.

    • Marked as answer by Lemon Trui Wednesday, August 21, 2013 2:34 AM
    • Unmarked as answer by Lemon Trui Wednesday, August 21, 2013 7:10 AM
    Tuesday, August 20, 2013 10:26 PM
  • Hi, Serge

    I changed the Zindex property of dragging scatterview item to 100, and it was still under the librarycontainer...


    Wednesday, August 21, 2013 7:14 AM