hover/active/focus)Primary APIs:
:pointerover, :pressed, :focus, :disabledKeyBinding, HotKeyManagerReference docs:
18-input-system-and-routed-events.md19-focus-and-keyboard-navigation.md24-commands-hotkeys-and-gestures.mdhover/active/focus)| HTML/CSS | Avalonia |
|---|---|
:hover |
:pointerover |
:active |
:pressed |
:focus |
:focus |
:disabled |
:disabled |
HTML/CSS:
.btn:hover { background:#3355cc; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity:.45; cursor:not-allowed; }
Avalonia:
<Style Selector="Button.btn:pointerover">
<Setter Property="Background" Value="#3355CC" />
</Style>
<Style Selector="Button.btn:pressed">
<Setter Property="RenderTransform" Value="scale(0.98)" />
</Style>
<Style Selector="Button.btn:disabled">
<Setter Property="Opacity" Value="0.45" />
</Style>
Web idiom:
.btn:focus-visible { outline: 2px solid #67a3ff; outline-offset: 2px; }
Avalonia pattern:
<Style Selector="Button.btn:focus">
<Setter Property="BorderBrush" Value="#67A3FF" />
<Setter Property="BorderThickness" Value="2" />
</Style>
| Web interaction | Avalonia mapping |
|---|---|
| click | Button.Command / routed Click |
| dblclick | DoubleTapped |
| contextmenu | ContextMenu / right tap |
| pointerdown/up/move | pointer/routed input events |
| keyboard shortcut | KeyBinding / HotKeyManager |
Minimal command + hotkey example:
<Button Classes="btn" Content="Refresh" Command="{CompiledBinding RefreshCommand}" />
HotKeyManager.SetHotKey(myButton, new KeyGesture(Key.R, KeyModifiers.Control));
HTML/CSS:
<div class="cmdbar">
<button class="btn">Search</button>
<button class="btn">Filter</button>
<button class="btn primary">Apply</button>
</div>
.cmdbar { display:flex; gap:8px; }
.btn { transition: background .12s ease, transform .12s ease; }
Avalonia:
<StackPanel Orientation="Horizontal" Spacing="8">
<Button Classes="btn" Content="Search" />
<Button Classes="btn" Content="Filter" />
<Button Classes="btn primary" Content="Apply" Command="{CompiledBinding ApplyCommand}" />
</StackPanel>
using Avalonia.Controls;
using Avalonia.Input;
var commandBar = new StackPanel
{
Orientation = Avalonia.Layout.Orientation.Horizontal,
Spacing = 8
};
var searchButton = new Button { Content = "Search" };
var filterButton = new Button { Content = "Filter" };
var applyButton = new Button { Content = "Apply" };
HotKeyManager.SetHotKey(applyButton, new KeyGesture(Key.Enter, KeyModifiers.Control));
commandBar.Children.Add(searchButton);
commandBar.Children.Add(filterButton);
commandBar.Children.Add(applyButton);
KeyBinding policies and avoid duplicate gestures.