Browse Source

InheritDataTypeFromItems for DisplayMemberBinding & cleanup ItemsControl

pull/10180/head
amwx 4 years ago
parent
commit
c80cdd1d3a
  1. 31
      src/Avalonia.Controls/ItemsControl.cs

31
src/Avalonia.Controls/ItemsControl.cs

@ -2,7 +2,6 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Automation.Peers; using Avalonia.Automation.Peers;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Controls.Generators; using Avalonia.Controls.Generators;
@ -17,7 +16,6 @@ using Avalonia.Layout;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
using Avalonia.Metadata; using Avalonia.Metadata;
using Avalonia.Styling; using Avalonia.Styling;
using Avalonia.VisualTree;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
@ -91,10 +89,11 @@ namespace Avalonia.Controls
/// Gets or sets the <see cref="IBinding"/> to use for binding to the display member of each item. /// Gets or sets the <see cref="IBinding"/> to use for binding to the display member of each item.
/// </summary> /// </summary>
[AssignBinding] [AssignBinding]
[InheritDataTypeFromItems(nameof(Items))]
public IBinding? DisplayMemberBinding public IBinding? DisplayMemberBinding
{ {
get { return GetValue(DisplayMemberBindingProperty); } get => GetValue(DisplayMemberBindingProperty);
set { SetValue(DisplayMemberBindingProperty, value); } set => SetValue(DisplayMemberBindingProperty, value);
} }
private IEnumerable? _items = new AvaloniaList<object>(); private IEnumerable? _items = new AvaloniaList<object>();
@ -134,8 +133,8 @@ namespace Avalonia.Controls
[Content] [Content]
public IEnumerable? Items public IEnumerable? Items
{ {
get { return _items; } get => _items;
set { SetAndRaise(ItemsProperty, ref _items, value); } set => SetAndRaise(ItemsProperty, ref _items, value);
} }
/// <summary> /// <summary>
@ -143,8 +142,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public ControlTheme? ItemContainerTheme public ControlTheme? ItemContainerTheme
{ {
get { return GetValue(ItemContainerThemeProperty); } get => GetValue(ItemContainerThemeProperty);
set { SetValue(ItemContainerThemeProperty, value); } set => SetValue(ItemContainerThemeProperty, value);
} }
/// <summary> /// <summary>
@ -161,8 +160,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public ITemplate<Panel> ItemsPanel public ITemplate<Panel> ItemsPanel
{ {
get { return GetValue(ItemsPanelProperty); } get => GetValue(ItemsPanelProperty);
set { SetValue(ItemsPanelProperty, value); } set => SetValue(ItemsPanelProperty, value);
} }
/// <summary> /// <summary>
@ -171,8 +170,8 @@ namespace Avalonia.Controls
[InheritDataTypeFromItems(nameof(Items))] [InheritDataTypeFromItems(nameof(Items))]
public IDataTemplate? ItemTemplate public IDataTemplate? ItemTemplate
{ {
get { return GetValue(ItemTemplateProperty); } get => GetValue(ItemTemplateProperty);
set { SetValue(ItemTemplateProperty, value); } set => SetValue(ItemTemplateProperty, value);
} }
/// <summary> /// <summary>
@ -264,8 +263,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public bool AreHorizontalSnapPointsRegular public bool AreHorizontalSnapPointsRegular
{ {
get { return GetValue(AreHorizontalSnapPointsRegularProperty); } get => GetValue(AreHorizontalSnapPointsRegularProperty);
set { SetValue(AreHorizontalSnapPointsRegularProperty, value); } set => SetValue(AreHorizontalSnapPointsRegularProperty, value);
} }
/// <summary> /// <summary>
@ -273,8 +272,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public bool AreVerticalSnapPointsRegular public bool AreVerticalSnapPointsRegular
{ {
get { return GetValue(AreVerticalSnapPointsRegularProperty); } get => GetValue(AreVerticalSnapPointsRegularProperty);
set { SetValue(AreVerticalSnapPointsRegularProperty, value); } set => SetValue(AreVerticalSnapPointsRegularProperty, value);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save