Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

managing-wpf-popup-focus

verified

Manages focus behavior for WPF Popup controls using PreviewMouseDown events. Use when Popup loses focus unexpectedly or needs to stay open during user interaction.

View on GitHub

Marketplace

dotnet-claude-plugins

christian289/dotnet-with-claudecode

Plugin

wpf-dev-pack

development

Repository

christian289/dotnet-with-claudecode
6stars

wpf-dev-pack/skills/managing-wpf-popup-focus/SKILL.md

Last Verified

February 1, 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/managing-wpf-popup-focus/SKILL.md -a claude-code --skill managing-wpf-popup-focus

Installation paths:

Claude
.claude/skills/managing-wpf-popup-focus/
Powered by add-skill CLI

Instructions

# 5.7 Popup Control Usage Considerations

In WPF, the Popup control only operates correctly when the WPF Application has focus. When focus moves to another application, the Popup may not display or function properly.

#### 5.7.1 Focus Management Pattern

When using the Popup control in WPF, **you must forcibly acquire focus through the PreviewMouseDown event.**

## Project Structure

The templates folder contains a WPF project example (use latest .NET per version mapping).

```
templates/
└── WpfPopupSample.App/                  ← WPF Application
    ├── Views/
    │   ├── MainWindow.xaml
    │   └── MainWindow.xaml.cs           ← Focus management pattern implementation
    ├── App.xaml
    ├── App.xaml.cs
    ├── GlobalUsings.cs
    └── WpfPopupSample.App.csproj
```

#### 5.7.2 Core Principles

- **Popup operation condition**: Only operates when WPF Application has focus
- **PreviewMouseDown event**: Check focus state on mouse click
- **IsKeyboardFocused check**: Verify keyboard focus status
- **Activate() call**: Activate window to restore focus if not focused
- **For UserControl**: Activate parent window with `Window.GetWindow(this)?.Activate()`

#### 5.7.3 Why Is This Necessary?

1. **Focus moves to another app**: When user clicks another application and returns
2. **Background execution**: Ensure Popup operation when WPF app is in background
3. **User experience**: Ensure Popup always works as expected

**⚠️ Important Notes:**

- This pattern must be applied to all Windows using Popup

#### 5.7.4 References

- [WPF Popup Focus Issue - .NET Dev Forum](https://forum.dotnetdev.kr/t/wpf-popup/8296)

Validation Details

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