public void DisplayInsertIndicator(Card source, int idx) { // If the index corresponds to the card being dragged, it's a NOP so don't provide any visual feedback if (idx < Children.Count) { if (((FrameworkElement)Children[idx]).DataContext == source) { HideInsertIndicator(); return; } if (idx > 0 && ((FrameworkElement)Children[idx - 1]).DataContext == source) { HideInsertIndicator(); return; } } // Create an adorner if it doesn't exist yet if (insertAdorner == null) { insertAdorner = new InsertAdorner(this); var layer = AdornerLayer.GetAdornerLayer(this); layer.Add(insertAdorner); } // Position the insert adorner correctly insertAdorner.MoveTo(new Point(idx * itemSkipSize, 0)); // Cancel previous spacing CancelSpacing(); // Space neighbors if (idx < Children.Count) { spacedItem2 = Children[idx]; SetSpacing(spacedItem2, SpacingWidth); if (idx > 0) { spacedItem1 = Children[idx - 1]; SetSpacing(spacedItem1, -SpacingWidth); } } }
public void HideInsertIndicator() { if (insertAdorner == null) return; var layer = AdornerLayer.GetAdornerLayer(this); layer.Remove(insertAdorner); insertAdorner = null; CancelSpacing(); }