implementing-wpf-adorners

Solid

Implements WPF Adorner decoration layers with AdornerLayer, AdornerDecorator, and custom Adorner patterns. Use when building drag handles, validation indicators, watermarks, selection visuals, or resize grips.

AI & Automation 40 stars 6 forks Updated 6 days ago MIT

Install

View on GitHub

Quality Score: 78/100

Stars 20%
54
Recency 20%
100
Frontmatter 20%
40
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# WPF Adorner Patterns Adorner is a mechanism for overlaying decorative visual elements on top of UIElements. ## 1. Adorner Concept ### 1.1 Characteristics - **AdornerLayer**: Separate rendering layer that holds Adorners - **Z-Order**: Always renders above the adorned element - **Layout Independent**: No effect on target element's layout - **Event Support**: Can receive mouse/keyboard events ### 1.2 Usage Scenarios | Scenario | Description | |----------|-------------| | **Validation Display** | Input field error display | | **Drag Handles** | Element move/resize handles | | **Watermark** | Hint text for empty TextBox | | **Selection Display** | Highlight selected elements | | **Tooltip/Badge** | Additional info display on elements | | **Drag and Drop** | Preview during drag | --- ## 2. Basic Adorner Implementation ### 2.1 Simple Adorner ```csharp namespace MyApp.Adorners; using System.Windows; using System.Windows.Documents; using System.Windows.Media; /// <summary> /// Adorner that draws border around element /// </summary> public sealed class BorderAdorner : Adorner { private readonly Pen _borderPen; public BorderAdorner(UIElement adornedElement) : base(adornedElement) { _borderPen = new Pen(Brushes.Red, 2) { DashStyle = DashStyles.Dash }; _borderPen.Freeze(); // Disable mouse events (decoration only) IsHitTestVisible = false; } protected override void OnRender(DrawingContext draw...

Details

Author
christian289
Repository
christian289/dotnet-with-claudecode
Created
7 months ago
Last Updated
6 days ago
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category