avalonia-events

Create and manage Avalonia routed events across the UI tree.

27|2|Updated Apr 23, 2026
One-click install
npx skills add https://github.com/linuxdevel/Avalonia-skills --skill avalonia-events
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: avalonia-events
Source: https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-events
Command: npx skills add https://github.com/linuxdevel/Avalonia-skills --skill avalonia-events

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Avalonia routed events are central to building interactive UIs. This skill covers defining custom RoutedEvent, handling bubbling or tunneling, and wiring handlers with AddHandler, RoutingStrategies, the OnApplyTemplate/PART pattern, or class-level static handlers via AddClassHandler.

Core Features & Use Cases

  • Custom RoutedEvent creation and registration for controls.
  • Event routing across the visual tree with Bubble, Tunnel, and Direct strategies.
  • Template integration via OnApplyTemplate and PART pattern to wire parts safely.

Quick Start

Create a custom RoutedEvent on a control, attach handlers with AddHandler using the correct RoutingStrategies, and wire template parts in OnApplyTemplate.

Frequently Asked Questions about avalonia-events

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a custom routed event in Avalonia for a user control?

To create a custom routed event in Avalonia, you define and register a RoutedEvent on your control, then attach handlers using AddHandler with the appropriate RoutingStrategies. This enables controls to respond to pointer, keyboard, or custom interactions across the visual tree.

What is the difference between Bubble, Tunnel, and Direct routing strategies in Avalonia?

Avalonia routing strategies control event propagation across the visual tree. Bubble routes events upward from child to parent, Tunnel routes downward from parent to child, and Direct routes only to the originating control without traversing the visual tree.

How do I wire template parts safely using OnApplyTemplate and the PART_ pattern in Avalonia?

You override OnApplyTemplate in your Avalonia control to locate named template parts using the PART_ pattern. This allows you to safely wire event handlers to visual elements defined in the control template after it has been applied.

Can I attach class-level static event handlers for routed events in Avalonia?

Yes, you can attach static class-level handlers using AddClassHandler in Avalonia. This allows you to define routed event handling logic statically at the class level, ensuring consistent event behavior across all instances of a control without manually wiring each instance.

When should I use AddHandler instead of standard event subscription for Avalonia routed events?

Use AddHandler in Avalonia when you need to intercept routed events with specific RoutingStrategies, such as handling tunneling events before child controls process them, or when attaching handlers to events that bubble up through nested controls in the visual tree.