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>(
|
AvaloniaProperty.Register<MultiAutoCompleteBox, bool>(
|
||||||
nameof(IsDropDownOpen));
|
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>
|
/// <summary>
|
||||||
/// Identifies the <see cref="Text" /> property.
|
/// Identifies the <see cref="Text" /> property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -182,6 +172,16 @@ public partial class MultiAutoCompleteBox
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly StyledProperty<object?> InnerRightContentProperty =
|
public static readonly StyledProperty<object?> InnerRightContentProperty =
|
||||||
TextBox.InnerRightContentProperty.AddOwner<MultiAutoCompleteBox>();
|
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>
|
/// <summary>
|
||||||
/// Gets or sets the caret index
|
/// Gets or sets the caret index
|
||||||
@@ -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>
|
/// <summary>
|
||||||
/// Gets or sets the text in the text box portion of the
|
/// Gets or sets the text in the text box portion of the
|
||||||
/// <see cref="AutoCompleteBox" /> control.
|
/// <see cref="AutoCompleteBox" /> control.
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ using Avalonia.Input;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Avalonia.VisualTree;
|
using Avalonia.VisualTree;
|
||||||
|
using Irihi.Avalonia.Shared.Contracts;
|
||||||
using Irihi.Avalonia.Shared.Helpers;
|
using Irihi.Avalonia.Shared.Helpers;
|
||||||
using Ursa.Common;
|
using Ursa.Common;
|
||||||
|
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
public partial class MultiAutoCompleteBox : TemplatedControl
|
public partial class MultiAutoCompleteBox : TemplatedControl, IInnerContentControl
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the name of the selection adapter TemplatePart.
|
/// Specifies the name of the selection adapter TemplatePart.
|
||||||
@@ -181,7 +182,7 @@ public partial class MultiAutoCompleteBox : TemplatedControl
|
|||||||
MinimumPopulateDelayProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) =>
|
MinimumPopulateDelayProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) =>
|
||||||
x.OnMinimumPopulateDelayChanged(e));
|
x.OnMinimumPopulateDelayChanged(e));
|
||||||
IsDropDownOpenProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnIsDropDownOpenChanged(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));
|
TextProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnTextPropertyChanged(e));
|
||||||
SearchTextProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnSearchTextPropertyChanged(e));
|
SearchTextProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnSearchTextPropertyChanged(e));
|
||||||
FilterModeProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnFilterModePropertyChanged(e));
|
FilterModeProperty.Changed.AddClassHandler<MultiAutoCompleteBox>((x, e) => x.OnFilterModePropertyChanged(e));
|
||||||
@@ -589,7 +590,10 @@ public partial class MultiAutoCompleteBox : TemplatedControl
|
|||||||
BindingValueType state,
|
BindingValueType state,
|
||||||
Exception? error)
|
Exception? error)
|
||||||
{
|
{
|
||||||
if (property == TextProperty || property == SelectedItemProperty) DataValidationErrors.SetError(this, error);
|
if (property == TextProperty || property == SelectedItemProperty)
|
||||||
|
{
|
||||||
|
DataValidationErrors.SetError(this, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user