diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs index ae7e43f511..81d379ce05 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs @@ -114,7 +114,7 @@ namespace ControlCatalog.Pages foreach (AutoCompleteBox box in GetAllAutoCompleteBox().Where(x => x.Name != "CustomAutocompleteBox")) { - box.Items = States; + box.ItemsSource = States; } var converter = new FuncMultiValueConverter(parts => @@ -132,7 +132,7 @@ namespace ControlCatalog.Pages asyncBox.AsyncPopulator = PopulateAsync; var customAutocompleteBox = this.Get("CustomAutocompleteBox"); - customAutocompleteBox.Items = Sentences.SelectMany(x => x); + customAutocompleteBox.ItemsSource = Sentences.SelectMany(x => x); customAutocompleteBox.TextFilter = LastWordContains; customAutocompleteBox.TextSelector = AppendWord; } diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml b/samples/ControlCatalog/Pages/DialogsPage.xaml index 90c717e7ed..980b210aaa 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml @@ -45,7 +45,7 @@ - + Desktop Documents @@ -54,7 +54,7 @@ Videos Music - + - /// Identifies the property. + /// Identifies the property. /// - /// The identifier for the property. - public static readonly StyledProperty ItemsProperty = + /// The identifier for the property. + public static readonly StyledProperty ItemsSourceProperty = AvaloniaProperty.Register( - nameof(Items)); + nameof(ItemsSource)); /// /// Identifies the property. @@ -311,10 +311,10 @@ namespace Avalonia.Controls /// /// Gets the text that is used to filter items in the - /// item collection. + /// item collection. /// /// The text that is used to filter items in the - /// item collection. + /// item collection. /// /// The SearchText value is typically the same as the /// Text property, but is set after the TextChanged event occurs @@ -339,7 +339,7 @@ namespace Avalonia.Controls /// /// Gets or sets how the text in the text box is used to filter items - /// specified by the + /// specified by the /// property for display in the drop-down. /// /// One of the @@ -366,11 +366,11 @@ namespace Avalonia.Controls /// /// Gets or sets the custom method that uses user-entered text to filter - /// the items specified by the + /// 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 + /// the items specified by the /// property. The default is null. /// /// The filter mode is automatically set to Custom if you set the @@ -384,11 +384,11 @@ namespace Avalonia.Controls /// /// Gets or sets the custom method that uses the user-entered text to - /// filter items specified by the + /// 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 + /// 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 @@ -402,11 +402,11 @@ namespace Avalonia.Controls /// /// Gets or sets the custom method that combines the user-entered - /// text and one of the items specified by the . + /// 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 . + /// text and one of the items specified by the . /// public AutoCompleteSelector? ItemSelector { @@ -417,11 +417,11 @@ namespace Avalonia.Controls /// /// 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. + /// in a text-based way. /// /// /// The custom method that combines the user-entered - /// text and one of the items specified by the + /// text and one of the items specified by the /// in a text-based way. /// public AutoCompleteSelector? TextSelector @@ -442,10 +442,10 @@ namespace Avalonia.Controls /// /// The collection that is used to generate the items of the /// drop-down portion of the control. - public IEnumerable? Items + public IEnumerable? ItemsSource { - get => GetValue(ItemsProperty); - set => SetValue(ItemsProperty, value); + get => GetValue(ItemsSourceProperty); + set => SetValue(ItemsSourceProperty, value); } } } diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs index 72a23144cf..e10cc1d100 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs @@ -419,9 +419,9 @@ namespace Avalonia.Controls /// ItemsSourceProperty property changed handler. /// /// Event arguments. - private void OnItemsPropertyChanged(AvaloniaPropertyChangedEventArgs e) + private void OnItemsSourcePropertyChanged(AvaloniaPropertyChangedEventArgs e) { - OnItemsChanged((IEnumerable?)e.NewValue); + OnItemsSourceChanged((IEnumerable?)e.NewValue); } private void OnItemTemplatePropertyChanged(AvaloniaPropertyChangedEventArgs e) @@ -461,7 +461,7 @@ namespace Avalonia.Controls SearchTextProperty.Changed.AddClassHandler((x,e) => x.OnSearchTextPropertyChanged(e)); FilterModeProperty.Changed.AddClassHandler((x,e) => x.OnFilterModePropertyChanged(e)); ItemFilterProperty.Changed.AddClassHandler((x,e) => x.OnItemFilterPropertyChanged(e)); - ItemsProperty.Changed.AddClassHandler((x,e) => x.OnItemsPropertyChanged(e)); + ItemsSourceProperty.Changed.AddClassHandler((x,e) => x.OnItemsSourcePropertyChanged(e)); ItemTemplateProperty.Changed.AddClassHandler((x,e) => x.OnItemTemplatePropertyChanged(e)); IsEnabledProperty.Changed.AddClassHandler((x,e) => x.OnControlIsEnabledChanged(e)); } @@ -559,7 +559,7 @@ namespace Avalonia.Controls _adapter.Commit -= OnAdapterSelectionComplete; _adapter.Cancel -= OnAdapterSelectionCanceled; _adapter.Cancel -= OnAdapterSelectionComplete; - _adapter.Items = null; + _adapter.ItemsSource = null; } _adapter = value; @@ -570,7 +570,7 @@ namespace Avalonia.Controls _adapter.Commit += OnAdapterSelectionComplete; _adapter.Cancel += OnAdapterSelectionCanceled; _adapter.Cancel += OnAdapterSelectionComplete; - _adapter.Items = _view; + _adapter.ItemsSource = _view; } } } @@ -1128,7 +1128,7 @@ namespace Avalonia.Controls { if (!cancellationToken.IsCancellationRequested) { - SetCurrentValue(ItemsProperty, resultList); + SetCurrentValue(ItemsSourceProperty, resultList); PopulateComplete(); } }); @@ -1475,7 +1475,7 @@ namespace Avalonia.Controls /// adapter's ItemsSource to the view if appropriate. /// /// The new enumerable reference. - private void OnItemsChanged(IEnumerable? newValue) + private void OnItemsSourceChanged(IEnumerable? newValue) { // Remove handler for oldValue.CollectionChanged (if present) _collectionChangeSubscription?.Dispose(); @@ -1492,9 +1492,9 @@ namespace Avalonia.Controls // Clear and set the view on the selection adapter ClearView(); - if (SelectionAdapter != null && SelectionAdapter.Items != _view) + if (SelectionAdapter != null && SelectionAdapter.ItemsSource != _view) { - SelectionAdapter.Items = _view; + SelectionAdapter.ItemsSource = _view; } if (IsDropDownOpen) { @@ -1545,9 +1545,9 @@ namespace Avalonia.Controls { // Significant changes to the underlying data. ClearView(); - if (Items != null) + if (ItemsSource != null) { - _items = new List(Items.Cast()); + _items = new List(ItemsSource.Cast()); } } @@ -1582,9 +1582,9 @@ namespace Avalonia.Controls PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection(_view!)); OnPopulated(populated); - if (SelectionAdapter != null && SelectionAdapter.Items != _view) + if (SelectionAdapter != null && SelectionAdapter.ItemsSource != _view) { - SelectionAdapter.Items = _view; + SelectionAdapter.ItemsSource = _view; } bool isDropDownOpen = _userCalledPopulate && (_view!.Count > 0); diff --git a/src/Avalonia.Controls/Utils/ISelectionAdapter.cs b/src/Avalonia.Controls/Utils/ISelectionAdapter.cs index 3ede518ffa..55739500a1 100644 --- a/src/Avalonia.Controls/Utils/ISelectionAdapter.cs +++ b/src/Avalonia.Controls/Utils/ISelectionAdapter.cs @@ -36,7 +36,7 @@ namespace Avalonia.Controls.Utils /// /// The collection that is used to generate content for the /// selection adapter. - IEnumerable? Items { get; set; } + IEnumerable? ItemsSource { get; set; } /// /// Occurs when a selected item is not cancelled and is committed as the diff --git a/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs b/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs index 5f528e2c72..ca8827eb45 100644 --- a/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs +++ b/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs @@ -140,7 +140,7 @@ namespace Avalonia.Controls.Utils /// /// The collection used to generate content for the selection /// adapter. - public IEnumerable? Items + public IEnumerable? ItemsSource { get { diff --git a/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs b/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs index 4582659763..acae583b5c 100644 --- a/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs @@ -89,7 +89,7 @@ namespace Avalonia.Controls.UnitTests bool closeEvent = false; control.DropDownOpened += (s, e) => openEvent = true; control.DropDownClosed += (s, e) => closeEvent = true; - control.Items = CreateSimpleStringArray(); + control.ItemsSource = CreateSimpleStringArray(); textbox.Text = "a"; Dispatcher.UIThread.RunJobs(); @@ -258,7 +258,7 @@ namespace Avalonia.Controls.UnitTests control.FilterMode = AutoCompleteFilterMode.None; control.Populating += (s, e) => { - control.Items = new string[] { custom }; + control.ItemsSource = new string[] { custom }; Assert.Equal(search, e.Parameter); }; control.Populated += (s, e) => @@ -380,7 +380,7 @@ namespace Avalonia.Controls.UnitTests { RunTest((control, textbox) => { - object selectedItem = control.Items.Cast().First(); + object selectedItem = control.ItemsSource.Cast().First(); string input = "42"; control.TextSelector = (text, item) => text + item; @@ -397,7 +397,7 @@ namespace Avalonia.Controls.UnitTests { RunTest((control, textbox) => { - object selectedItem = control.Items.Cast().First(); + object selectedItem = control.ItemsSource.Cast().First(); string input = "42"; control.ItemSelector = (text, item) => text + item; @@ -1053,7 +1053,7 @@ namespace Avalonia.Controls.UnitTests using (UnitTestApplication.Start(Services)) { AutoCompleteBox control = CreateControl(); - control.Items = CreateSimpleStringArray(); + control.ItemsSource = CreateSimpleStringArray(); TextBox textBox = GetTextBox(control); var window = new Window {Content = control}; window.ApplyStyling();