Primary WPF APIs:
TextBox, PasswordBoxComboBox (IsEditable, IsTextSearchEnabled)Primary Avalonia APIs:
TextBox (PasswordChar for masked entry)ComboBoxAutoCompleteBox for suggestion-heavy entry| WPF | Avalonia |
|---|---|
TextBox.Text |
TextBox.Text |
PasswordBox.Password |
TextBox PasswordChar="*" or custom secure-entry pattern |
ComboBox IsEditable="True" |
ComboBox IsEditable="True" |
ComboBox IsTextSearchEnabled="True" |
ComboBox IsTextSearchEnabled="True" |
| watermark via style/template | Watermark properties on text entry controls |
WPF XAML:
<StackPanel>
<TextBox Text="{Binding UserName, Mode=TwoWay}" />
<PasswordBox />
<ComboBox ItemsSource="{Binding Roles}"
SelectedItem="{Binding SelectedRole, Mode=TwoWay}"
IsEditable="True"
IsTextSearchEnabled="True" />
</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:LoginViewModel">
<StackPanel Spacing="8">
<TextBox Watermark="User name"
Text="{CompiledBinding UserName, Mode=TwoWay}" />
<TextBox Watermark="Password"
PasswordChar="*"
Text="{CompiledBinding Password, Mode=TwoWay}" />
<ComboBox ItemsSource="{CompiledBinding Roles}"
SelectedItem="{CompiledBinding SelectedRole, Mode=TwoWay}"
IsEditable="True"
IsTextSearchEnabled="True" />
<AutoCompleteBox ItemsSource="{CompiledBinding Roles}"
MinimumPrefixLength="1"
Text="{CompiledBinding RoleSearch, Mode=TwoWay}"
SelectedItem="{CompiledBinding SelectedRole, Mode=TwoWay}" />
</StackPanel>
</UserControl>
using Avalonia.Controls;
var user = new TextBox { Watermark = "User name", Text = viewModel.UserName };
var password = new TextBox
{
Watermark = "Password",
PasswordChar = '*',
Text = viewModel.Password
};
var role = new ComboBox
{
ItemsSource = viewModel.Roles,
SelectedItem = viewModel.SelectedRole,
IsEditable = true,
IsTextSearchEnabled = true
};
var roleSearch = new AutoCompleteBox
{
ItemsSource = viewModel.Roles,
MinimumPrefixLength = 1,
Text = viewModel.RoleSearch,
SelectedItem = viewModel.SelectedRole
};
ComboBox IsEditable/IsTextSearchEnabled; use AutoCompleteBox when custom filtering/population behavior is required.