static void gallery_Drop(object sender, DragEventArgs e) { e.Handled = true; if (dragableItem != null) { HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, e.GetPosition((GalleryControl)sender)); if (res.VisualHit == null) { return; } GalleryItemControl target = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit); if (target != null && target.Item != dragableItem) { GalleryItemCollection targetCollection = target.Item.Group.Items; GalleryItemCollection sourceCollection = dragableItem.Group.Items; int targetIndex = targetCollection.IndexOf(target.Item); if (targetCollection == sourceCollection) { targetCollection.Move(originalIndex, targetIndex); } else { sourceCollection.Remove(dragableItem); targetCollection.Insert(targetIndex, dragableItem); } dragableItem = null; } } }
static void Gallery_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { clickPoint = e.GetPosition((GalleryControl)sender); HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, clickPoint); if (res.VisualHit == null) { return; } gic = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit); if (gic != null) { dragableItem = gic.Item; container = dragableItem.Group; originalIndex = container.Items.IndexOf(dragableItem); } }
private void GalleryControl_MouseRightButtonUp_1(object sender, MouseButtonEventArgs e) { HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, e.GetPosition((GalleryControl)sender)); if (res.VisualHit == null) { return; } GalleryItemControl galleryItemControl = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit); if (galleryItemControl != null) { object capt = galleryItemControl.ActualCaption; GalleryItem tmpIt = MyDict[capt]; tmpIt.IsChecked = !tmpIt.IsChecked; } }