feat: implement SelectedItems property in MultiAutoCompleteBox and remove SelectedItem property
This commit is contained in:
@@ -78,16 +78,6 @@ public partial class MultiAutoCompleteBox
|
||||
AvaloniaProperty.Register<MultiAutoCompleteBox, bool>(
|
||||
nameof(IsDropDownOpen));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="SelectedItem" /> property.
|
||||
/// </summary>
|
||||
/// <value>The identifier the <see cref="SelectedItem" /> property.</value>
|
||||
public static readonly StyledProperty<object?> SelectedItemProperty =
|
||||
AvaloniaProperty.Register<MultiAutoCompleteBox, object?>(
|
||||
nameof(SelectedItem),
|
||||
defaultBindingMode: BindingMode.TwoWay,
|
||||
enableDataValidation: true);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Text" /> property.
|
||||
/// </summary>
|
||||
@@ -183,6 +173,16 @@ public partial class MultiAutoCompleteBox
|
||||
public static readonly StyledProperty<object?> InnerRightContentProperty =
|
||||
TextBox.InnerRightContentProperty.AddOwner<MultiAutoCompleteBox>();
|
||||
|
||||
public static readonly StyledProperty<IList?> SelectedItemsProperty =
|
||||
AvaloniaProperty.Register<MultiAutoCompleteBox, IList?>(
|
||||
nameof(SelectedItems));
|
||||
|
||||
public IList? SelectedItems
|
||||
{
|
||||
get => GetValue(SelectedItemsProperty);
|
||||
set => SetValue(SelectedItemsProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the caret index
|
||||
/// </summary>
|
||||
@@ -316,22 +316,6 @@ public partial class MultiAutoCompleteBox
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected item in the drop-down.
|
||||
/// </summary>
|
||||
/// <value>The selected item in the drop-down.</value>
|
||||
/// <remarks>
|
||||
/// If the IsTextCompletionEnabled property is true and text typed by
|
||||
/// the user matches an item in the ItemsSource collection, which is
|
||||
/// then displayed in the text box, the SelectedItem property will be
|
||||
/// a null reference.
|
||||
/// </remarks>
|
||||
public object? SelectedItem
|
||||
{
|
||||
get => GetValue(SelectedItemProperty);
|
||||
set => SetValue(SelectedItemProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text in the text box portion of the
|
||||
/// <see cref="AutoCompleteBox" /> control.
|
||||
|
||||
@@ -14,13 +14,14 @@ using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using Irihi.Avalonia.Shared.Contracts;
|
||||
using Irihi.Avalonia.Shared.Helpers;
|
||||
using Ursa.Common;
|
||||
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public partial class MultiAutoCompleteBox : TemplatedControl
|
||||
public partial class MultiAutoCompleteBox : TemplatedControl, IInnerContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the name of the selection adapter TemplatePart.
|
||||
@@ -181,7 +182,7 @@ public partial class MultiAutoCompleteBox : TemplatedControl
|
||||
MinimumPopulateDelayProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) =>
|
||||
x.OnMinimumPopulateDelayChanged(e));
|
||||
IsDropDownOpenProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnIsDropDownOpenChanged(e));
|
||||
SelectedItemProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnSelectedItemPropertyChanged(e));
|
||||
// SelectedItemProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnSelectedItemPropertyChanged(e));
|
||||
TextProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnTextPropertyChanged(e));
|
||||
SearchTextProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnSearchTextPropertyChanged(e));
|
||||
FilterModeProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnFilterModePropertyChanged(e));
|
||||
@@ -589,7 +590,10 @@ public partial class MultiAutoCompleteBox : TemplatedControl
|
||||
BindingValueType state,
|
||||
Exception? error)
|
||||
{
|
||||
if (property == TextProperty || property == SelectedItemProperty) DataValidationErrors.SetError(this, error);
|
||||
if (property == TextProperty || property == SelectedItemProperty)
|
||||
{
|
||||
DataValidationErrors.SetError(this, error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user