private bool start_drag(ListBoxItem item, object data, TouchDevice touch_device, ImageSource i)
{
Image i2 = new Image();
i2.Source = i; i2.Stretch = Stretch.Uniform;
item_generic i3 = null;
try { i3 = (item_generic)item.Content; }
catch (Exception) { }
ContentControl cursorVisual = new ContentControl();
if (i3 != null)
cursorVisual.Content = i3.get_clone();
else
cursorVisual.Content = i2;
cursorVisual.Style = (FindResource("CursorStyle") as Style);
//SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged);
List<InputDevice> devices = new List<InputDevice>();
devices.Add(touch_device);
foreach (TouchDevice touch in item.TouchesCapturedWithin)
{
if (touch != touch_device)
{
devices.Add(touch);
}
}
FrameworkElement element = item;
if (configurations.use_avatar_drag)
element = ((item_generic)(item.DataContext)).avatar;
Microsoft.Surface.Presentation.SurfaceDragCursor startDragOkay =
Microsoft.Surface.Presentation.SurfaceDragDrop.BeginDragDrop(
this._list, // The SurfaceListBox object that the cursor is dragged out from.
element, // The SurfaceListBoxItem object that is dragged from the drag source.
cursorVisual, // The visual element of the cursor.
data, // The data associated with the cursor.
devices, // The input devices that start dragging the cursor.
DragDropEffects.Copy); // The allowed drag-and-drop effects of the operation.
return (startDragOkay != null);
}