Primary WPF APIs:
_File, AccessText)Label.TargetKeyboardNavigation.TabNavigation, TabIndexFocusManager.IsFocusScopePrimary Avalonia APIs:
_) + AccessText behavior in templatesLabel.TargetKeyboardNavigation.TabNavigation, KeyboardNavigation.TabIndex, KeyboardNavigation.IsTabStopFocusManager usage through TopLevel.FocusManagerIn Avalonia, focus scopes are defined by controls implementing IFocusScope (for example top-level roots), not by setting a public IsFocusScope attached property.
| WPF | Avalonia |
|---|---|
_Save / AccessText |
_Save marker works on common controls; template ContentPresenter can opt into access-key parsing |
Label Target="{Binding ElementName=...}" |
Label Target="{Binding #...}" |
KeyboardNavigation.TabNavigation |
KeyboardNavigation.TabNavigation |
KeyboardNavigation.TabIndex |
KeyboardNavigation.TabIndex |
WPF XAML:
<StackPanel KeyboardNavigation.TabNavigation="Cycle">
<Label Content="_Name" Target="{Binding ElementName=NameBox}" />
<TextBox x:Name="NameBox" TabIndex="0" />
<Button Content="_Save" TabIndex="1" />
</StackPanel>
Avalonia XAML:
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:MyApp.ViewModels"
x:DataType="vm:ProfileViewModel">
<StackPanel KeyboardNavigation.TabNavigation="Cycle" Spacing="8">
<Label Content="_Name" Target="{Binding #NameBox}" />
<TextBox x:Name="NameBox"
KeyboardNavigation.TabIndex="0"
Text="{CompiledBinding Name, Mode=TwoWay}" />
<Label Content="_Email" Target="{Binding #EmailBox}" />
<TextBox x:Name="EmailBox"
KeyboardNavigation.TabIndex="1"
Text="{CompiledBinding Email, Mode=TwoWay}" />
<Button Content="_Save"
KeyboardNavigation.TabIndex="2"
Command="{CompiledBinding SaveCommand}" />
</StackPanel>
</UserControl>
using Avalonia.Controls;
using Avalonia.Input;
var panel = new StackPanel { Spacing = 8 };
KeyboardNavigation.SetTabNavigation(panel, KeyboardNavigationMode.Cycle);
var nameBox = new TextBox();
KeyboardNavigation.SetTabIndex(nameBox, 0);
var emailBox = new TextBox();
KeyboardNavigation.SetTabIndex(emailBox, 1);
var save = new Button { Content = "_Save", Command = viewModel.SaveCommand };
KeyboardNavigation.SetTabIndex(save, 2);
var nameLabel = new Label { Content = "_Name", Target = nameBox };
var emailLabel = new Label { Content = "_Email", Target = emailBox };
panel.Children.Add(nameLabel);
panel.Children.Add(nameBox);
panel.Children.Add(emailLabel);
panel.Children.Add(emailBox);
panel.Children.Add(save);
Label.Target points to a focusable input element.KeyboardNavigation.TabIndex explicitly on critical form fields.KeyboardNavigation.TabNavigation intentionally on container roots (Cycle, Local, etc.).