From c80cdd1d3ac6c7b248b3df06e5b954ddd288cb23 Mon Sep 17 00:00:00 2001 From: amwx <40413319+amwx@users.noreply.github.com> Date: Wed, 8 Feb 2023 17:53:12 -0500 Subject: [PATCH] InheritDataTypeFromItems for DisplayMemberBinding & cleanup ItemsControl --- src/Avalonia.Controls/ItemsControl.cs | 31 +++++++++++++-------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index 59b5bf48a5..aa62ae3e71 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; -using System.Diagnostics.CodeAnalysis; using Avalonia.Automation.Peers; using Avalonia.Collections; using Avalonia.Controls.Generators; @@ -17,7 +16,6 @@ using Avalonia.Layout; using Avalonia.LogicalTree; using Avalonia.Metadata; using Avalonia.Styling; -using Avalonia.VisualTree; namespace Avalonia.Controls { @@ -91,10 +89,11 @@ namespace Avalonia.Controls /// Gets or sets the to use for binding to the display member of each item. /// [AssignBinding] + [InheritDataTypeFromItems(nameof(Items))] public IBinding? DisplayMemberBinding { - get { return GetValue(DisplayMemberBindingProperty); } - set { SetValue(DisplayMemberBindingProperty, value); } + get => GetValue(DisplayMemberBindingProperty); + set => SetValue(DisplayMemberBindingProperty, value); } private IEnumerable? _items = new AvaloniaList(); @@ -134,8 +133,8 @@ namespace Avalonia.Controls [Content] public IEnumerable? Items { - get { return _items; } - set { SetAndRaise(ItemsProperty, ref _items, value); } + get => _items; + set => SetAndRaise(ItemsProperty, ref _items, value); } /// @@ -143,8 +142,8 @@ namespace Avalonia.Controls /// public ControlTheme? ItemContainerTheme { - get { return GetValue(ItemContainerThemeProperty); } - set { SetValue(ItemContainerThemeProperty, value); } + get => GetValue(ItemContainerThemeProperty); + set => SetValue(ItemContainerThemeProperty, value); } /// @@ -161,8 +160,8 @@ namespace Avalonia.Controls /// public ITemplate ItemsPanel { - get { return GetValue(ItemsPanelProperty); } - set { SetValue(ItemsPanelProperty, value); } + get => GetValue(ItemsPanelProperty); + set => SetValue(ItemsPanelProperty, value); } /// @@ -171,8 +170,8 @@ namespace Avalonia.Controls [InheritDataTypeFromItems(nameof(Items))] public IDataTemplate? ItemTemplate { - get { return GetValue(ItemTemplateProperty); } - set { SetValue(ItemTemplateProperty, value); } + get => GetValue(ItemTemplateProperty); + set => SetValue(ItemTemplateProperty, value); } /// @@ -264,8 +263,8 @@ namespace Avalonia.Controls /// public bool AreHorizontalSnapPointsRegular { - get { return GetValue(AreHorizontalSnapPointsRegularProperty); } - set { SetValue(AreHorizontalSnapPointsRegularProperty, value); } + get => GetValue(AreHorizontalSnapPointsRegularProperty); + set => SetValue(AreHorizontalSnapPointsRegularProperty, value); } /// @@ -273,8 +272,8 @@ namespace Avalonia.Controls /// public bool AreVerticalSnapPointsRegular { - get { return GetValue(AreVerticalSnapPointsRegularProperty); } - set { SetValue(AreVerticalSnapPointsRegularProperty, value); } + get => GetValue(AreVerticalSnapPointsRegularProperty); + set => SetValue(AreVerticalSnapPointsRegularProperty, value); } ///