private void Root2_MouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; e.Handled = true; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the dragged ListViewItem ItemsControl itemControl = sender as ItemsControl; MonumentRow itemControlItem1 = Map.FindAncestor <MonumentRow>((DependencyObject)e.OriginalSource); Monument monument; if (itemControlItem1 == null) { MonumentRowDetail itemControlItem2 = Map.FindAncestor <MonumentRowDetail>((DependencyObject)e.OriginalSource); monument = (Monument)itemControlItem2.DataContext; } else { monument = (Monument)itemControlItem1.DataContext; } // Find the data behind the ListViewItem // Initialize the drag & drop operation DataObject dragData = new DataObject("myFormat", monument); DragDrop.DoDragDrop((DependencyObject)e.OriginalSource, dragData, DragDropEffects.Move); } }
public void monumentClicked(int id) { this.UpdateLayout(); MonumentRow myMonumentUC = null; MonumentRowDetail myMonumentDUC = null; foreach (MonumentRow tb in FindVisualChildren <MonumentRow>(RootWoot)) { tb.Visibility = Visibility.Visible; if (tb.Tag.Equals(id)) { myMonumentUC = tb; } else { this.EnlargenedMonuments.Remove(tb.MonumentId); } } foreach (MonumentRowDetail tb in FindVisualChildren <MonumentRowDetail>(RootWoot)) { tb.Visibility = Visibility.Collapsed; if (tb.Tag.Equals(id)) { myMonumentDUC = tb; } else { this.EnlargenedMonuments.Remove(tb.MonumentId); } } if (myMonumentUC != null && myMonumentDUC != null) { if (this.EnlargenedMonuments.IndexOf(id) == -1) { myMonumentUC.Visibility = Visibility.Collapsed; myMonumentDUC.Visibility = Visibility.Visible; this.EnlargenedMonuments.Add(id); } else { myMonumentDUC.Visibility = Visibility.Collapsed; myMonumentUC.Visibility = Visibility.Visible; this.EnlargenedMonuments.Remove(id); } MonumentSelectionChangedCallback(); } }