Browse Source
feat(AutoCompleteBox): Added MaxLength (#14592)
* feat(AutoCompleteBox): Added MaxLength
* fix: Address review
pull/14621/head
workgroupengineering
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
23 additions and
2 deletions
-
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs
-
src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml
-
src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml
|
|
|
@ -167,6 +167,12 @@ namespace Avalonia.Controls |
|
|
|
AvaloniaProperty.Register<AutoCompleteBox, Func<string?, CancellationToken, Task<IEnumerable<object>>>?>( |
|
|
|
nameof(AsyncPopulator)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="MaxLength"/> property
|
|
|
|
/// </summary>
|
|
|
|
public static readonly StyledProperty<int> MaxLengthProperty = |
|
|
|
TextBox.MaxLengthProperty.AddOwner<AutoCompleteBox>(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the caret index
|
|
|
|
/// </summary>
|
|
|
|
@ -466,5 +472,16 @@ namespace Avalonia.Controls |
|
|
|
get => GetValue(ItemsSourceProperty); |
|
|
|
set => SetValue(ItemsSourceProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the maximum number of characters that the <see cref="AutoCompleteBox"/> can accept.
|
|
|
|
/// This constraint only applies for manually entered (user-inputted) text.
|
|
|
|
/// </summary>
|
|
|
|
public int MaxLength |
|
|
|
{ |
|
|
|
get => GetValue(MaxLengthProperty); |
|
|
|
set => SetValue(MaxLengthProperty, value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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}" |
|
|
|
/> |
|
|
|
<Popup Name="PART_Popup" |
|
|
|
WindowManagerAddShadowHint="False" |
|
|
|
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|
|
|
|
|
|
|
@ -18,7 +18,9 @@ |
|
|
|
CornerRadius="{TemplateBinding CornerRadius}" |
|
|
|
CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}" |
|
|
|
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" |
|
|
|
Watermark="{TemplateBinding Watermark}" /> |
|
|
|
Watermark="{TemplateBinding Watermark}" |
|
|
|
MaxLength="{TemplateBinding MaxLength}" |
|
|
|
/> |
|
|
|
|
|
|
|
<Popup Name="PART_Popup" |
|
|
|
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" |
|
|
|
|