Browse Source

feat(AutoCompleteBox): Add InnerLeftContent and InnerRightContent (#14610)

* feat: AutoCompleteBox InnerLeftContent

* fix: Address review

* fix: null annotation

* fix: merge nits
pull/14627/head
workgroupengineering 2 years ago
committed by GitHub
parent
commit
59f8c68066
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 33
      src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs
  2. 2
      src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml
  3. 4
      src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml

33
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs

@ -173,6 +173,18 @@ namespace Avalonia.Controls
public static readonly StyledProperty<int> MaxLengthProperty =
TextBox.MaxLengthProperty.AddOwner<AutoCompleteBox>();
/// <summary>
/// Defines the <see cref="InnerLeftContent"/> property
/// </summary>
public static readonly StyledProperty<object?> InnerLeftContentProperty =
TextBox.InnerLeftContentProperty.AddOwner<AutoCompleteBox>();
/// <summary>
/// Defines the <see cref="InnerRightContent"/> property
/// </summary>
public static readonly StyledProperty<object?> InnerRightContentProperty =
TextBox.InnerRightContentProperty.AddOwner<AutoCompleteBox>();
/// <summary>
/// Gets or sets the caret index
/// </summary>
@ -472,8 +484,7 @@ 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.
@ -483,5 +494,23 @@ namespace Avalonia.Controls
get => GetValue(MaxLengthProperty);
set => SetValue(MaxLengthProperty, value);
}
/// <summary>
/// Gets or sets custom content that is positioned on the left side of the text layout box
/// </summary>
public object? InnerLeftContent
{
get => GetValue(InnerLeftContentProperty);
set => SetValue(InnerLeftContentProperty, value);
}
/// <summary>
/// Gets or sets custom content that is positioned on the right side of the text layout box
/// </summary>
public object? InnerRightContent
{
get => GetValue(InnerRightContentProperty);
set => SetValue(InnerRightContentProperty, value);
}
}
}

2
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}"
/>
<Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"

4
src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml

@ -19,7 +19,9 @@
CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Watermark="{TemplateBinding Watermark}"
MaxLength="{TemplateBinding MaxLength}"
MaxLength="{TemplateBinding MaxLength}"
InnerLeftContent="{TemplateBinding InnerLeftContent}"
InnerRightContent="{TemplateBinding InnerRightContent}"
/>
<Popup Name="PART_Popup"

Loading…
Cancel
Save