private void RemoveAdornerLayer() { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(adornerContainer); if (adornerLayer != null) { adornerLayer.Remove(pickupDragAdorner); pickupDragAdorner = null; } }
private bool InitializeAdornerLayer() { // Create a brush which will paint the ListViewItem onto // a visual in the adorner layer. VisualBrush brush = new VisualBrush(pickupElement); adornerContainer = (UIElement)this.Parent; // Create an element which displays the source item while it is dragged. this.pickupDragAdorner = new DragAdorner(adornerContainer, pickupElement.RenderSize, brush); this.pickupDragAdorner.UseLayoutRounding = true; this.pickupDragAdorner.SnapsToDevicePixels = true; AdornerLayer layer = AdornerLayer.GetAdornerLayer(adornerContainer); if (layer != null) { layer.Add(pickupDragAdorner); return true; } return false; }