Browse Source

Merge pull request #10137 from robloo/treeviewitem-styledproperty

Switch TreeViewItem.IsExpanded to a StyledProperty
pull/10155/head
Max Katz 3 years ago
committed by GitHub
parent
commit
0a11b450ee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      src/Avalonia.Controls/TreeViewItem.cs

29
src/Avalonia.Controls/TreeViewItem.cs

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Controls.Generators;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Mixins;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.LogicalTree;
using Avalonia.Threading;
@ -22,11 +22,10 @@ namespace Avalonia.Controls
/// <summary>
/// Defines the <see cref="IsExpanded"/> property.
/// </summary>
public static readonly DirectProperty<TreeViewItem, bool> IsExpandedProperty =
AvaloniaProperty.RegisterDirect<TreeViewItem, bool>(
public static readonly StyledProperty<bool> IsExpandedProperty =
AvaloniaProperty.Register<TreeViewItem, bool>(
nameof(IsExpanded),
o => o.IsExpanded,
(o, v) => o.IsExpanded = v);
defaultBindingMode: BindingMode.TwoWay);
/// <summary>
/// Defines the <see cref="IsSelected"/> property.
@ -46,7 +45,6 @@ namespace Avalonia.Controls
private TreeView? _treeView;
private Control? _header;
private bool _isExpanded;
private int _level;
private bool _templateApplied;
private bool _deferredBringIntoViewFlag;
@ -68,8 +66,8 @@ namespace Avalonia.Controls
/// </summary>
public bool IsExpanded
{
get { return _isExpanded; }
set { SetAndRaise(IsExpandedProperty, ref _isExpanded, value); }
get => GetValue(IsExpandedProperty);
set => SetValue(IsExpandedProperty, value);
}
/// <summary>
@ -77,8 +75,8 @@ namespace Avalonia.Controls
/// </summary>
public bool IsSelected
{
get { return GetValue(IsSelectedProperty); }
set { SetValue(IsSelectedProperty, value); }
get => GetValue(IsSelectedProperty);
set => SetValue(IsSelectedProperty, value);
}
/// <summary>
@ -86,8 +84,8 @@ namespace Avalonia.Controls
/// </summary>
public int Level
{
get { return _level; }
private set { SetAndRaise(LevelProperty, ref _level, value); }
get => _level;
private set => SetAndRaise(LevelProperty, ref _level, value);
}
internal TreeView? TreeViewOwner => _treeView;
@ -115,11 +113,6 @@ namespace Avalonia.Controls
}
}
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
{
base.OnDetachedFromLogicalTree(e);
}
protected virtual void OnRequestBringIntoView(RequestBringIntoViewEventArgs e)
{
if (e.TargetObject == this)
@ -266,7 +259,7 @@ namespace Avalonia.Controls
}
/// <summary>
/// Invoked when the <see cref="DoubleTapped"/> event occurs in the header.
/// Invoked when the <see cref="InputElement.DoubleTapped"/> event occurs in the header.
/// </summary>
protected virtual void OnHeaderDoubleTapped(TappedEventArgs e)
{

Loading…
Cancel
Save