private void PinnedItems_Drop(object sender, SurfaceDragDropEventArgs e)
        {
            DragableImageItem  image = e.Cursor.Data as DragableImageItem;
            SurfaceListBoxItem s     = (SurfaceListBoxItem)sender;

            BluetoothHandler.SendBluetooth((s.Content as PhoneThumbVisualization).BTEndpoint, image.Image);
        }
        private void StackPanel_Drop(object sender, SurfaceDragDropEventArgs e)
        {
            DragableImageItem item = e.Cursor.Data as DragableImageItem;

            if (BTEndpoint != null)
            {
                BluetoothHandler.SendBluetooth(BTEndpoint, item.Image);
            }
        }
        private void ImgScatterView_DragCanceled(object sender, SurfaceDragDropEventArgs e)
        {
            DragableImageItem data = e.Cursor.Data as DragableImageItem;
            ScatterViewItem   item = data.DraggedElement as ScatterViewItem;

            if (item != null)
            {
                item.Visibility  = Visibility.Visible;
                item.Orientation = e.Cursor.GetOrientation(this);
                item.Center      = e.Cursor.GetPosition(this);
            }
        }
        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)
            {
                return;
            }

            DragableImageItem data = draggedElement.Content as DragableImageItem;

            // If the data has not been specified as draggable,
            // or the ScatterViewItem cannot move, return.
            if (data == null || !data.CanDrag || !draggedElement.CanMove)
            {
                return;
            }

            // 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>();

            devices.Add(e.Device);

            // 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)
                {
                    devices.Add(device);
                }
            }

            // Get the drag source object.
            ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement);

            // Start the drag-and-drop operation.
            SurfaceDragCursor cursor =
                SurfaceDragDrop.BeginDragDrop(
                    // The ScatterView object that the cursor is dragged out from.
                    dragSource,
                    // The ScatterViewItem object that is dragged from the drag source.
                    draggedElement,
                    // The visual element of the cursor.
                    cursorVisual,
                    // The data attached with the cursor.
                    draggedElement.DataContext,
                    // The input devices that start dragging the cursor.
                    devices,
                    // The allowed drag-and-drop effects of the operation.
                    DragDropEffects.Move);

            // 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;
            }
        }