From d86cb35d3b815b90c5f3410f97576ed5f5e2ef2d Mon Sep 17 00:00:00 2001 From: robloo Date: Fri, 14 Oct 2022 20:38:31 -0400 Subject: [PATCH] Separate out public AutoCompleteBox properties --- .../AutoCompleteBox.Properties.cs | 540 ++++++++++++++++++ .../AutoCompleteBox/AutoCompleteBox.cs | 533 +---------------- 2 files changed, 549 insertions(+), 524 deletions(-) create mode 100644 src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs new file mode 100644 index 0000000000..4f70f8271e --- /dev/null +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs @@ -0,0 +1,540 @@ +// (c) Copyright Microsoft Corporation. +// This source is subject to the Microsoft Public License (Ms-PL). +// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details. +// All other rights reserved. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Avalonia.Controls.Templates; +using Avalonia.Data; + +namespace Avalonia.Controls +{ + public partial class AutoCompleteBox + { + public static readonly StyledProperty WatermarkProperty = + TextBox.WatermarkProperty.AddOwner(); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly StyledProperty MinimumPrefixLengthProperty = + AvaloniaProperty.Register( + nameof(MinimumPrefixLength), 1, + validate: IsValidMinimumPrefixLength); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly StyledProperty MinimumPopulateDelayProperty = + AvaloniaProperty.Register( + nameof(MinimumPopulateDelay), + TimeSpan.Zero, + validate: IsValidMinimumPopulateDelay); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly StyledProperty MaxDropDownHeightProperty = + AvaloniaProperty.Register( + nameof(MaxDropDownHeight), + double.PositiveInfinity, + validate: IsValidMaxDropDownHeight); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly StyledProperty IsTextCompletionEnabledProperty = + AvaloniaProperty.Register(nameof(IsTextCompletionEnabled)); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly StyledProperty ItemTemplateProperty = + AvaloniaProperty.Register(nameof(ItemTemplate)); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty IsDropDownOpenProperty = + AvaloniaProperty.RegisterDirect( + nameof(IsDropDownOpen), + o => o.IsDropDownOpen, + (o, v) => o.IsDropDownOpen = v); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier the + /// + /// dependency property. + public static readonly DirectProperty SelectedItemProperty = + AvaloniaProperty.RegisterDirect( + nameof(SelectedItem), + o => o.SelectedItem, + (o, v) => o.SelectedItem = v, + defaultBindingMode: BindingMode.TwoWay, + enableDataValidation: true); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty TextProperty = + TextBlock.TextProperty.AddOwnerWithDataValidation( + o => o.Text, + (o, v) => o.Text = v, + defaultBindingMode: BindingMode.TwoWay, + enableDataValidation: true); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty SearchTextProperty = + AvaloniaProperty.RegisterDirect( + nameof(SearchText), + o => o.SearchText, + unsetValue: string.Empty); + + /// + /// Gets the identifier for the + /// + /// dependency property. + /// + public static readonly StyledProperty FilterModeProperty = + AvaloniaProperty.Register( + nameof(FilterMode), + defaultValue: AutoCompleteFilterMode.StartsWith, + validate: IsValidFilterMode); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty?> ItemFilterProperty = + AvaloniaProperty.RegisterDirect?>( + nameof(ItemFilter), + o => o.ItemFilter, + (o, v) => o.ItemFilter = v); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty?> TextFilterProperty = + AvaloniaProperty.RegisterDirect?>( + nameof(TextFilter), + o => o.TextFilter, + (o, v) => o.TextFilter = v, + unsetValue: AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.StartsWith)); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty?> ItemSelectorProperty = + AvaloniaProperty.RegisterDirect?>( + nameof(ItemSelector), + o => o.ItemSelector, + (o, v) => o.ItemSelector = v); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty?> TextSelectorProperty = + AvaloniaProperty.RegisterDirect?>( + nameof(TextSelector), + o => o.TextSelector, + (o, v) => o.TextSelector = v); + + /// + /// Identifies the + /// + /// dependency property. + /// + /// The identifier for the + /// + /// dependency property. + public static readonly DirectProperty ItemsProperty = + AvaloniaProperty.RegisterDirect( + nameof(Items), + o => o.Items, + (o, v) => o.Items = v); + + public static readonly DirectProperty>>?> AsyncPopulatorProperty = + AvaloniaProperty.RegisterDirect>>?>( + nameof(AsyncPopulator), + o => o.AsyncPopulator, + (o, v) => o.AsyncPopulator = v); + + /// + /// Gets or sets the minimum number of characters required to be entered + /// in the text box before the + /// displays + /// possible matches. + /// matches. + /// + /// + /// The minimum number of characters to be entered in the text box + /// before the + /// displays possible matches. The default is 1. + /// + /// + /// If you set MinimumPrefixLength to -1, the AutoCompleteBox will + /// not provide possible matches. There is no maximum value, but + /// setting MinimumPrefixLength to value that is too large will + /// prevent the AutoCompleteBox from providing possible matches as well. + /// + public int MinimumPrefixLength + { + get => GetValue(MinimumPrefixLengthProperty); + set => SetValue(MinimumPrefixLengthProperty, value); + } + + /// + /// Gets or sets a value indicating whether the first possible match + /// found during the filtering process will be displayed automatically + /// in the text box. + /// + /// + /// True if the first possible match found will be displayed + /// automatically in the text box; otherwise, false. The default is + /// false. + /// + public bool IsTextCompletionEnabled + { + get => GetValue(IsTextCompletionEnabledProperty); + set => SetValue(IsTextCompletionEnabledProperty, value); + } + + /// + /// Gets or sets the used + /// to display each item in the drop-down portion of the control. + /// + /// The used to + /// display each item in the drop-down. The default is null. + /// + /// You use the ItemTemplate property to specify the visualization + /// of the data objects in the drop-down portion of the AutoCompleteBox + /// control. If your AutoCompleteBox is bound to a collection and you + /// do not provide specific display instructions by using a + /// DataTemplate, the resulting UI of each item is a string + /// representation of each object in the underlying collection. + /// + public IDataTemplate ItemTemplate + { + get => GetValue(ItemTemplateProperty); + set => SetValue(ItemTemplateProperty, value); + } + + /// + /// Gets or sets the minimum delay, after text is typed + /// in the text box before the + /// control + /// populates the list of possible matches in the drop-down. + /// + /// The minimum delay, after text is typed in + /// the text box, but before the + /// populates + /// the list of possible matches in the drop-down. The default is 0. + public TimeSpan MinimumPopulateDelay + { + get => GetValue(MinimumPopulateDelayProperty); + set => SetValue(MinimumPopulateDelayProperty, value); + } + + /// + /// Gets or sets the maximum height of the drop-down portion of the + /// control. + /// + /// The maximum height of the drop-down portion of the + /// control. + /// The default is . + /// The specified value is less than 0. + public double MaxDropDownHeight + { + get => GetValue(MaxDropDownHeightProperty); + set => SetValue(MaxDropDownHeightProperty, value); + } + + /// + /// Gets or sets a value indicating whether the drop-down portion of + /// the control is open. + /// + /// + /// True if the drop-down is open; otherwise, false. The default is + /// false. + /// + public bool IsDropDownOpen + { + get => _isDropDownOpen; + set => SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value); + } + + /// + /// Gets or sets the that + /// is used to get the values for display in the text portion of + /// the + /// control. + /// + /// The object used + /// when binding to a collection property. + [AssignBinding] + public IBinding? ValueMemberBinding + { + get => _valueBindingEvaluator?.ValueBinding; + set + { + if (ValueMemberBinding != value) + { + _valueBindingEvaluator = new BindingEvaluator(value); + OnValueMemberBindingChanged(value); + } + } + } + + /// + /// Gets or sets the selected item in the drop-down. + /// + /// The selected item in the drop-down. + /// + /// 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. + /// + public object? SelectedItem + { + get => _selectedItem; + set => SetAndRaise(SelectedItemProperty, ref _selectedItem, value); + } + + /// + /// Gets or sets the text in the text box portion of the + /// control. + /// + /// The text in the text box portion of the + /// control. + public string? Text + { + get => _text; + set => SetAndRaise(TextProperty, ref _text, value); + } + + /// + /// Gets the text that is used to filter items in the + /// + /// item collection. + /// + /// The text that is used to filter items in the + /// + /// item collection. + /// + /// The SearchText value is typically the same as the + /// Text property, but is set after the TextChanged event occurs + /// and before the Populating event. + /// + public string? SearchText + { + get => _searchText; + private set + { + try + { + _allowWrite = true; + SetAndRaise(SearchTextProperty, ref _searchText, value); + } + finally + { + _allowWrite = false; + } + } + } + + /// + /// Gets or sets how the text in the text box is used to filter items + /// specified by the + /// + /// property for display in the drop-down. + /// + /// One of the + /// + /// values The default is + /// . + /// The specified value is + /// not a valid + /// . + /// + /// Use the FilterMode property to specify how possible matches are + /// filtered. For example, possible matches can be filtered in a + /// predefined or custom way. The search mode is automatically set to + /// Custom if you set the ItemFilter property. + /// + public AutoCompleteFilterMode FilterMode + { + get => GetValue(FilterModeProperty); + set => SetValue(FilterModeProperty, value); + } + + public string? Watermark + { + get => GetValue(WatermarkProperty); + set => SetValue(WatermarkProperty, value); + } + + /// + /// Gets or sets the custom method that uses user-entered text to filter + /// the items specified by the + /// + /// property for display in the drop-down. + /// + /// The custom method that uses the user-entered text to filter + /// the items specified by the + /// + /// property. The default is null. + /// + /// The filter mode is automatically set to Custom if you set the + /// ItemFilter property. + /// + public AutoCompleteFilterPredicate? ItemFilter + { + get => _itemFilter; + set => SetAndRaise(ItemFilterProperty, ref _itemFilter, value); + } + + /// + /// Gets or sets the custom method that uses the user-entered text to + /// filter items specified by the + /// + /// property in a text-based way for display in the drop-down. + /// + /// The custom method that uses the user-entered text to filter + /// items specified by the + /// + /// property in a text-based way for display in the drop-down. + /// + /// The search mode is automatically set to Custom if you set the + /// TextFilter property. + /// + public AutoCompleteFilterPredicate? TextFilter + { + get => _textFilter; + set => SetAndRaise(TextFilterProperty, ref _textFilter, value); + } + + /// + /// Gets or sets the custom method that combines the user-entered + /// text and one of the items specified by the + /// . + /// + /// + /// The custom method that combines the user-entered + /// text and one of the items specified by the + /// . + /// + public AutoCompleteSelector? ItemSelector + { + get => _itemSelector; + set => SetAndRaise(ItemSelectorProperty, ref _itemSelector, value); + } + + /// + /// Gets or sets the custom method that combines the user-entered + /// text and one of the items specified by the + /// + /// in a text-based way. + /// + /// + /// The custom method that combines the user-entered + /// text and one of the items specified by the + /// + /// in a text-based way. + /// + public AutoCompleteSelector? TextSelector + { + get => _textSelector; + set => SetAndRaise(TextSelectorProperty, ref _textSelector, value); + } + + public Func>>? AsyncPopulator + { + get => _asyncPopulator; + set => SetAndRaise(AsyncPopulatorProperty, ref _asyncPopulator, value); + } + + /// + /// Gets or sets a collection that is used to generate the items for the + /// drop-down portion of the + /// control. + /// + /// The collection that is used to generate the items of the + /// drop-down portion of the + /// control. + public IEnumerable? Items + { + get => _itemsEnumerable; + set => SetAndRaise(ItemsProperty, ref _itemsEnumerable, value); + } + } +} diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs index 608d18d0d3..a027b8b650 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs @@ -72,7 +72,7 @@ namespace Avalonia.Controls [TemplatePart(ElementSelectionAdapter, typeof(ISelectionAdapter))] [TemplatePart(ElementTextBox, typeof(TextBox))] [PseudoClasses(":dropdownopen")] - public class AutoCompleteBox : TemplatedControl + public partial class AutoCompleteBox : TemplatedControl { /// /// Specifies the name of the selection adapter TemplatePart. @@ -209,228 +209,22 @@ namespace Avalonia.Controls private readonly EventHandler _populateDropDownHandler; - public static readonly RoutedEvent SelectionChangedEvent = - RoutedEvent.Register(nameof(SelectionChanged), RoutingStrategies.Bubble, typeof(AutoCompleteBox)); - - public static readonly StyledProperty WatermarkProperty = - TextBox.WatermarkProperty.AddOwner(); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly StyledProperty MinimumPrefixLengthProperty = - AvaloniaProperty.Register( - nameof(MinimumPrefixLength), 1, - validate: IsValidMinimumPrefixLength); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly StyledProperty MinimumPopulateDelayProperty = - AvaloniaProperty.Register( - nameof(MinimumPopulateDelay), - TimeSpan.Zero, - validate: IsValidMinimumPopulateDelay); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly StyledProperty MaxDropDownHeightProperty = - AvaloniaProperty.Register( - nameof(MaxDropDownHeight), - double.PositiveInfinity, - validate: IsValidMaxDropDownHeight); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly StyledProperty IsTextCompletionEnabledProperty = - AvaloniaProperty.Register(nameof(IsTextCompletionEnabled)); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly StyledProperty ItemTemplateProperty = - AvaloniaProperty.Register(nameof(ItemTemplate)); - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty IsDropDownOpenProperty = - AvaloniaProperty.RegisterDirect( - nameof(IsDropDownOpen), - o => o.IsDropDownOpen, - (o, v) => o.IsDropDownOpen = v); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier the - /// - /// dependency property. - public static readonly DirectProperty SelectedItemProperty = - AvaloniaProperty.RegisterDirect( - nameof(SelectedItem), - o => o.SelectedItem, - (o, v) => o.SelectedItem = v, - defaultBindingMode: BindingMode.TwoWay, - enableDataValidation: true); - - /// - /// Identifies the - /// - /// dependency property. + /// /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty TextProperty = - TextBlock.TextProperty.AddOwnerWithDataValidation( - o => o.Text, - (o, v) => o.Text = v, - defaultBindingMode: BindingMode.TwoWay, - enableDataValidation: true); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty SearchTextProperty = - AvaloniaProperty.RegisterDirect( - nameof(SearchText), - o => o.SearchText, - unsetValue: string.Empty); - - /// - /// Gets the identifier for the - /// - /// dependency property. - /// - public static readonly StyledProperty FilterModeProperty = - AvaloniaProperty.Register( - nameof(FilterMode), - defaultValue: AutoCompleteFilterMode.StartsWith, - validate: IsValidFilterMode); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty?> ItemFilterProperty = - AvaloniaProperty.RegisterDirect?>( - nameof(ItemFilter), - o => o.ItemFilter, - (o, v) => o.ItemFilter = v); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty?> TextFilterProperty = - AvaloniaProperty.RegisterDirect?>( - nameof(TextFilter), - o => o.TextFilter, - (o, v) => o.TextFilter = v, - unsetValue: AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.StartsWith)); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty?> ItemSelectorProperty = - AvaloniaProperty.RegisterDirect?>( - nameof(ItemSelector), - o => o.ItemSelector, - (o, v) => o.ItemSelector = v); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty?> TextSelectorProperty = - AvaloniaProperty.RegisterDirect?>( - nameof(TextSelector), - o => o.TextSelector, - (o, v) => o.TextSelector = v); - - /// - /// Identifies the - /// - /// dependency property. - /// - /// The identifier for the - /// - /// dependency property. - public static readonly DirectProperty ItemsProperty = - AvaloniaProperty.RegisterDirect( - nameof(Items), - o => o.Items, - (o, v) => o.Items = v); - - public static readonly DirectProperty>>?> AsyncPopulatorProperty = - AvaloniaProperty.RegisterDirect>>?>( - nameof(AsyncPopulator), - o => o.AsyncPopulator, - (o, v) => o.AsyncPopulator = v); + public static readonly RoutedEvent SelectionChangedEvent = + RoutedEvent.Register( + nameof(SelectionChanged), + RoutingStrategies.Bubble, + typeof(AutoCompleteBox)); /// /// Defines the event. /// public static readonly RoutedEvent TextChangedEvent = RoutedEvent.Register( - nameof(TextChanged), RoutingStrategies.Bubble); + nameof(TextChanged), + RoutingStrategies.Bubble); private static bool IsValidMinimumPrefixLength(int value) => value >= -1; @@ -693,315 +487,6 @@ namespace Avalonia.Controls ClearView(); } - /// - /// Gets or sets the minimum number of characters required to be entered - /// in the text box before the - /// displays - /// possible matches. - /// matches. - /// - /// - /// The minimum number of characters to be entered in the text box - /// before the - /// displays possible matches. The default is 1. - /// - /// - /// If you set MinimumPrefixLength to -1, the AutoCompleteBox will - /// not provide possible matches. There is no maximum value, but - /// setting MinimumPrefixLength to value that is too large will - /// prevent the AutoCompleteBox from providing possible matches as well. - /// - public int MinimumPrefixLength - { - get => GetValue(MinimumPrefixLengthProperty); - set => SetValue(MinimumPrefixLengthProperty, value); - } - - /// - /// Gets or sets a value indicating whether the first possible match - /// found during the filtering process will be displayed automatically - /// in the text box. - /// - /// - /// True if the first possible match found will be displayed - /// automatically in the text box; otherwise, false. The default is - /// false. - /// - public bool IsTextCompletionEnabled - { - get => GetValue(IsTextCompletionEnabledProperty); - set => SetValue(IsTextCompletionEnabledProperty, value); - } - - /// - /// Gets or sets the used - /// to display each item in the drop-down portion of the control. - /// - /// The used to - /// display each item in the drop-down. The default is null. - /// - /// You use the ItemTemplate property to specify the visualization - /// of the data objects in the drop-down portion of the AutoCompleteBox - /// control. If your AutoCompleteBox is bound to a collection and you - /// do not provide specific display instructions by using a - /// DataTemplate, the resulting UI of each item is a string - /// representation of each object in the underlying collection. - /// - public IDataTemplate ItemTemplate - { - get => GetValue(ItemTemplateProperty); - set => SetValue(ItemTemplateProperty, value); - } - - /// - /// Gets or sets the minimum delay, after text is typed - /// in the text box before the - /// control - /// populates the list of possible matches in the drop-down. - /// - /// The minimum delay, after text is typed in - /// the text box, but before the - /// populates - /// the list of possible matches in the drop-down. The default is 0. - public TimeSpan MinimumPopulateDelay - { - get => GetValue(MinimumPopulateDelayProperty); - set => SetValue(MinimumPopulateDelayProperty, value); - } - - /// - /// Gets or sets the maximum height of the drop-down portion of the - /// control. - /// - /// The maximum height of the drop-down portion of the - /// control. - /// The default is . - /// The specified value is less than 0. - public double MaxDropDownHeight - { - get => GetValue(MaxDropDownHeightProperty); - set => SetValue(MaxDropDownHeightProperty, value); - } - - /// - /// Gets or sets a value indicating whether the drop-down portion of - /// the control is open. - /// - /// - /// True if the drop-down is open; otherwise, false. The default is - /// false. - /// - public bool IsDropDownOpen - { - get => _isDropDownOpen; - set => SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value); - } - - /// - /// Gets or sets the that - /// is used to get the values for display in the text portion of - /// the - /// control. - /// - /// The object used - /// when binding to a collection property. - [AssignBinding] - public IBinding? ValueMemberBinding - { - get => _valueBindingEvaluator?.ValueBinding; - set - { - if (ValueMemberBinding != value) - { - _valueBindingEvaluator = new BindingEvaluator(value); - OnValueMemberBindingChanged(value); - } - } - } - - /// - /// Gets or sets the selected item in the drop-down. - /// - /// The selected item in the drop-down. - /// - /// 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. - /// - public object? SelectedItem - { - get => _selectedItem; - set => SetAndRaise(SelectedItemProperty, ref _selectedItem, value); - } - - /// - /// Gets or sets the text in the text box portion of the - /// control. - /// - /// The text in the text box portion of the - /// control. - public string? Text - { - get => _text; - set => SetAndRaise(TextProperty, ref _text, value); - } - - /// - /// Gets the text that is used to filter items in the - /// - /// item collection. - /// - /// The text that is used to filter items in the - /// - /// item collection. - /// - /// The SearchText value is typically the same as the - /// Text property, but is set after the TextChanged event occurs - /// and before the Populating event. - /// - public string? SearchText - { - get => _searchText; - private set - { - try - { - _allowWrite = true; - SetAndRaise(SearchTextProperty, ref _searchText, value); - } - finally - { - _allowWrite = false; - } - } - } - - /// - /// Gets or sets how the text in the text box is used to filter items - /// specified by the - /// - /// property for display in the drop-down. - /// - /// One of the - /// - /// values The default is - /// . - /// The specified value is - /// not a valid - /// . - /// - /// Use the FilterMode property to specify how possible matches are - /// filtered. For example, possible matches can be filtered in a - /// predefined or custom way. The search mode is automatically set to - /// Custom if you set the ItemFilter property. - /// - public AutoCompleteFilterMode FilterMode - { - get => GetValue(FilterModeProperty); - set => SetValue(FilterModeProperty, value); - } - - public string? Watermark - { - get => GetValue(WatermarkProperty); - set => SetValue(WatermarkProperty, value); - } - - /// - /// Gets or sets the custom method that uses user-entered text to filter - /// the items specified by the - /// - /// property for display in the drop-down. - /// - /// The custom method that uses the user-entered text to filter - /// the items specified by the - /// - /// property. The default is null. - /// - /// The filter mode is automatically set to Custom if you set the - /// ItemFilter property. - /// - public AutoCompleteFilterPredicate? ItemFilter - { - get => _itemFilter; - set => SetAndRaise(ItemFilterProperty, ref _itemFilter, value); - } - - /// - /// Gets or sets the custom method that uses the user-entered text to - /// filter items specified by the - /// - /// property in a text-based way for display in the drop-down. - /// - /// The custom method that uses the user-entered text to filter - /// items specified by the - /// - /// property in a text-based way for display in the drop-down. - /// - /// The search mode is automatically set to Custom if you set the - /// TextFilter property. - /// - public AutoCompleteFilterPredicate? TextFilter - { - get => _textFilter; - set => SetAndRaise(TextFilterProperty, ref _textFilter, value); - } - - /// - /// Gets or sets the custom method that combines the user-entered - /// text and one of the items specified by the - /// . - /// - /// - /// The custom method that combines the user-entered - /// text and one of the items specified by the - /// . - /// - public AutoCompleteSelector? ItemSelector - { - get => _itemSelector; - set => SetAndRaise(ItemSelectorProperty, ref _itemSelector, value); - } - - /// - /// Gets or sets the custom method that combines the user-entered - /// text and one of the items specified by the - /// - /// in a text-based way. - /// - /// - /// The custom method that combines the user-entered - /// text and one of the items specified by the - /// - /// in a text-based way. - /// - public AutoCompleteSelector? TextSelector - { - get => _textSelector; - set => SetAndRaise(TextSelectorProperty, ref _textSelector, value); - } - - public Func>>? AsyncPopulator - { - get => _asyncPopulator; - set => SetAndRaise(AsyncPopulatorProperty, ref _asyncPopulator, value); - } - - /// - /// Gets or sets a collection that is used to generate the items for the - /// drop-down portion of the - /// control. - /// - /// The collection that is used to generate the items of the - /// drop-down portion of the - /// control. - public IEnumerable? Items - { - get => _itemsEnumerable; - set => SetAndRaise(ItemsProperty, ref _itemsEnumerable, value); - } - /// /// Gets or sets the drop down popup control. ///