← ClaudeAtlas

implementing-wpf-dragdroplisted

Implements WPF drag and drop functionality using DragDrop.DoDragDrop, DataObject, and drag/drop events. Use when building file drop zones, list reordering, or inter-application data transfer.
christian289/dotnet-with-claudecode · ★ 41 · AI & Automation · score 73
Install: claude install-skill christian289/dotnet-with-claudecode
# WPF Drag and Drop Patterns Implementing drag and drop functionality for data transfer within and between applications. **Advanced Patterns:** See [ADVANCED.md](ADVANCED.md) for visual feedback, list reordering, and custom data formats. ## 1. Drag and Drop Overview ``` Drag Source Drop Target │ │ ├─ MouseDown │ ├─ MouseMove (drag threshold) │ ├─ DragDrop.DoDragDrop()───────────────┤ │ ├─ DragEnter │ ├─ DragOver │ ├─ DragLeave │ └─ Drop └─ GiveFeedback (cursor change) ``` --- ## 2. Basic Drag Source ### 2.1 Simple Text Drag ```csharp namespace MyApp.Views; using System.Windows; using System.Windows.Controls; using System.Windows.Input; public partial class DragSourceView : UserControl { private Point _startPoint; private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { _startPoint = e.GetPosition(null); } private void TextBlock_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) return; var currentPoint = e.GetPosition(null); var diff = _startPoint - currentPoint; // Check if drag threshold is exceeded if (Math.Abs(diff.X) > SystemParamet