Back to Skills

implementing-wpf-dragdrop

verified

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.

View on GitHub

Marketplace

dotnet-claude-plugins

christian289/dotnet-with-claudecode

Plugin

wpf-dev-pack

development

Repository

christian289/dotnet-with-claudecode
5stars

wpf-dev-pack/skills/implementing-wpf-dragdrop/SKILL.md

Last Verified

January 23, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/christian289/dotnet-with-claudecode/blob/main/wpf-dev-pack/skills/implementing-wpf-dragdrop/SKILL.md -a claude-code --skill implementing-wpf-dragdrop

Installation paths:

Claude
.claude/skills/implementing-wpf-dragdrop/
Powered by add-skill CLI

Instructions

# 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) > SystemParameters.MinimumHorizontalDragDistance ||
            Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
        {
            if (sender is TextBlock textBlock)
            {
                // Create data object and start drag
                var data = new DataObject(DataFormats.Text, textBlock.Text);
                DragDrop.DoDragDrop(textBlock, data, DragDropEffects.Copy);
            }
        }
    }
}
```

### 2.2 Multiple Data Formats

```csharp
private void StartDragWithMulti

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
6678 chars