diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs index 05b08af31f..4895b0eadc 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs @@ -167,6 +167,12 @@ namespace Avalonia.Controls AvaloniaProperty.Register>>?>( nameof(AsyncPopulator)); + /// + /// Defines the property + /// + public static readonly StyledProperty MaxLengthProperty = + TextBox.MaxLengthProperty.AddOwner(); + /// /// Gets or sets the caret index /// @@ -466,5 +472,16 @@ namespace Avalonia.Controls get => GetValue(ItemsSourceProperty); set => SetValue(ItemsSourceProperty, value); } + + + /// + /// Gets or sets the maximum number of characters that the can accept. + /// This constraint only applies for manually entered (user-inputted) text. + /// + public int MaxLength + { + get => GetValue(MaxLengthProperty); + set => SetValue(MaxLengthProperty, value); + } } } diff --git a/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml index 5ade49fab0..7789efa51d 100644 --- a/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml @@ -44,7 +44,9 @@ CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}" Padding="{TemplateBinding Padding}" Margin="0" - DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" /> + DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" + MaxLength="{TemplateBinding MaxLength}" + /> + Watermark="{TemplateBinding Watermark}" + MaxLength="{TemplateBinding MaxLength}" + />