From 59f8c680667dfcdc8f1f8377371f660665318b9f Mon Sep 17 00:00:00 2001 From: workgroupengineering Date: Fri, 16 Feb 2024 03:00:14 +0100 Subject: [PATCH] feat(AutoCompleteBox): Add InnerLeftContent and InnerRightContent (#14610) * feat: AutoCompleteBox InnerLeftContent * fix: Address review * fix: null annotation * fix: merge nits --- .../AutoCompleteBox.Properties.cs | 33 +++++++++++++++++-- .../Controls/AutoCompleteBox.xaml | 2 ++ .../Controls/AutoCompleteBox.xaml | 4 ++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs index 4895b0eadc..70be01e316 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs @@ -173,6 +173,18 @@ namespace Avalonia.Controls public static readonly StyledProperty MaxLengthProperty = TextBox.MaxLengthProperty.AddOwner(); + /// + /// Defines the property + /// + public static readonly StyledProperty InnerLeftContentProperty = + TextBox.InnerLeftContentProperty.AddOwner(); + + /// + /// Defines the property + /// + public static readonly StyledProperty InnerRightContentProperty = + TextBox.InnerRightContentProperty.AddOwner(); + /// /// Gets or sets the caret index /// @@ -472,8 +484,7 @@ 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. @@ -483,5 +494,23 @@ namespace Avalonia.Controls get => GetValue(MaxLengthProperty); set => SetValue(MaxLengthProperty, value); } + + /// + /// Gets or sets custom content that is positioned on the left side of the text layout box + /// + public object? InnerLeftContent + { + get => GetValue(InnerLeftContentProperty); + set => SetValue(InnerLeftContentProperty, value); + } + + /// + /// Gets or sets custom content that is positioned on the right side of the text layout box + /// + public object? InnerRightContent + { + get => GetValue(InnerRightContentProperty); + set => SetValue(InnerRightContentProperty, value); + } } } diff --git a/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml index 7789efa51d..3d9db1de3b 100644 --- a/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml @@ -46,6 +46,8 @@ Margin="0" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" MaxLength="{TemplateBinding MaxLength}" + InnerLeftContent="{TemplateBinding InnerLeftContent}" + InnerRightContent="{TemplateBinding InnerRightContent}" />