protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (mDraggedElement != null) { Win32Drag.POINT screenPos = new Win32Drag.POINT(); if (Win32Drag.GetCursorPos(ref screenPos)) { tempCursorPoint = screenPos; Point pos = PointFromScreen(new Point(screenPos.X, screenPos.Y)); Rect rect = new Rect(pos.X, pos.Y, mDraggedElement.ActualWidth, mDraggedElement.ActualHeight); drawingContext.PushOpacity(0.5); Brush highlight = mDraggedElement.TryFindResource(SystemColors.ControlDarkColorKey) as Brush; if (highlight != null) { drawingContext.DrawRectangle(highlight, new Pen(Brushes.Transparent, 0), rect); } drawingContext.DrawRectangle(new VisualBrush(mDraggedElement), new Pen(Brushes.Transparent, 0), rect); drawingContext.Pop(); } } }
public DragDropAdorner(UIElement parent) : base(parent) { IsHitTestVisible = false; // Seems Adorner is hit test visible? mDraggedElement = parent as FrameworkElement; Win32Drag.GetCursorPos(ref tempCursorPoint); }