Primary WinUI APIs:
Primary Avalonia APIs:
| WinUI idiom | Avalonia idiom |
|---|---|
| TextBox.InputScope | TextInputOptions.ContentType |
| Return key hints | TextInputOptions.ReturnKeyType |
| Undo/Redo APIs | Undo/Redo APIs on TextBox |
| SelectionStart + SelectionLength | SelectionStart + SelectionEnd/SelectAll |
| TextChanging/TextChanged | TextChanging/TextChanged |
WinUI XAML:
<TextBox x:Name="Editor"
Text="{x:Bind ViewModel.Query, Mode=TwoWay}"
InputScope="Search"
AcceptsReturn="True" />
WinUI C#:
if (Editor.CanUndo)
Editor.Undo();
Editor.SelectionStart = 0;
Editor.SelectionLength = Editor.Text?.Length ?? 0;
Avalonia XAML:
<TextBox xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Editor"
Text="{Binding Query}"
AcceptsReturn="True"
TextInputOptions.ContentType="Search"
TextInputOptions.ReturnKeyType="Search" />
Avalonia C#:
if (Editor.CanUndo)
Editor.Undo();
Editor.SelectAll();
if (Editor.CanRedo)
Editor.Redo();
InputScope intent to TextInputOptions attached properties.CanUndo/CanRedo.