Agent skill
managing-wpf-popup-focus
Manages focus behavior for WPF Popup controls using PreviewMouseDown events. Use when Popup loses focus unexpectedly or needs to stay open during user interaction.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/managing-wpf-popup-focus-christian289-dotnet-with-claudeco-2
SKILL.md
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?
- Focus moves to another app: When user clicks another application and returns
- Background execution: Ensure Popup operation when WPF app is in background
- User experience: Ensure Popup always works as expected
⚠️ Important Notes:
- This pattern must be applied to all Windows using Popup
5.7.4 References
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?