private void DropTarget_DragSourceDropped(object sender, SL_Drag_Drop_BaseClasses.DropEventArgs args) { // switch items in list // dropped content ListContent droppedContent = (ListContent)args.DragSource.DataContext; // dragsource that should be replaced ListContent toBeReplacedContent = (ListContent)(((DropTarget)sender).DataContext); // find the items int sourceIndex = itemList.IndexOf(droppedContent); int targetIndex = itemList.IndexOf(toBeReplacedContent); // replace items if (sourceIndex < targetIndex) { itemList.RemoveAt(targetIndex); itemList.Insert(sourceIndex, toBeReplacedContent); itemList.RemoveAt(sourceIndex + 1); itemList.Insert(targetIndex, droppedContent); } else if (sourceIndex > targetIndex) { itemList.RemoveAt(sourceIndex); itemList.Insert(targetIndex, droppedContent); itemList.RemoveAt(targetIndex + 1); itemList.Insert(sourceIndex, toBeReplacedContent); } }
private void DropTarget_DragSourceDropped(object sender, SL_Drag_Drop_BaseClasses.DropEventArgs args) { if (args.DragSource.Tag.ToString() == "Camera") { lblContent.Text += "You've added a camera to your luggage. \n"; } else if (args.DragSource.Tag.ToString() == "Coffee") { lblContent.Text += "You've added a cup of coffee to your luggage (don't spill!). \n"; } else if (args.DragSource.Tag.ToString() == "News") { lblContent.Text += "You've added today's newspaper to your luggage. \n"; } }
private void DropTarget_DragSourceDropped(object sender, SL_Drag_Drop_BaseClasses.DropEventArgs args) { if (args.DragSource.Tag.ToString() == "FullBattery") { lstItems.Add(new ListContent() { ItemText = "Full" , ImageSrc = new BitmapImage(new Uri("Images/battery_full.png", UriKind.RelativeOrAbsolute)) }); } else if (args.DragSource.Tag.ToString() == "HalfBattery") { lstItems.Add(new ListContent() { ItemText = "Half" , ImageSrc = new BitmapImage(new Uri("Images/battery_half.png", UriKind.RelativeOrAbsolute)) }); } else if (args.DragSource.Tag.ToString() == "EmptyBattery") { lstItems.Add(new ListContent() { ItemText = "Empty" , ImageSrc = new BitmapImage(new Uri("Images/battery_empty.png", UriKind.RelativeOrAbsolute)) }); } }
private void DropTarget_DragSourceDropped(object sender, SL_Drag_Drop_BaseClasses.DropEventArgs args) { // switch items in list // dropped content ListContent droppedContent = (ListContent)args.DragSource.DataContext; // dragsource that should be replaced ListContent toBeReplacedContent = (ListContent)(((DropTarget)sender).DataContext); // find the items ObservableCollection<ListContent> sourceList; ObservableCollection<ListContent> targetList; if (leftItems.IndexOf(droppedContent) > -1) { sourceList = leftItems; } else { sourceList = rightItems; } if (leftItems.IndexOf(toBeReplacedContent) > -1) { targetList = leftItems; } else { targetList = rightItems; } int sourceIndex = sourceList.IndexOf(droppedContent); int targetIndex = targetList.IndexOf(toBeReplacedContent); // replace items if (sourceList != targetList) { sourceList.RemoveAt(sourceIndex); targetList.RemoveAt(targetIndex); sourceList.Insert(sourceIndex, toBeReplacedContent); targetList.Insert(targetIndex, droppedContent); } else { if (sourceIndex < targetIndex) { sourceList.RemoveAt(targetIndex); sourceList.Insert(sourceIndex, toBeReplacedContent); sourceList.RemoveAt(sourceIndex +1); sourceList.Insert(targetIndex, droppedContent); } else if (sourceIndex > targetIndex) { sourceList.RemoveAt(sourceIndex); sourceList.Insert(targetIndex, droppedContent); sourceList.RemoveAt(targetIndex +1); sourceList.Insert(sourceIndex, toBeReplacedContent); } } }
private void DragSource_DragStarted(object sender, SL_Drag_Drop_BaseClasses.DragEventArgs args) { _timer.Start(); _position = args.MouseEventArgs.GetPosition(Scroller); }
private void DragSource_DragFinished(object sender, SL_Drag_Drop_BaseClasses.DragEventArgs args) { _timer.Stop(); }