Browse Source

Use styled properties in Expander.

`ContentTransition` was defined as a direct property, but was also getting set in a style, causing #2508. Changed it to be a styled property, along with `ExpandDirection`.

Fixes #2508
pull/2532/head
Steven Kirk 7 years ago
parent
commit
ed6251fbe8
  1. 29
      src/Avalonia.Controls/Expander.cs

29
src/Avalonia.Controls/Expander.cs

@ -13,18 +13,11 @@ namespace Avalonia.Controls
public class Expander : HeaderedContentControl public class Expander : HeaderedContentControl
{ {
public static readonly DirectProperty<Expander, IPageTransition> ContentTransitionProperty = public static readonly StyledProperty<IPageTransition> ContentTransitionProperty =
AvaloniaProperty.RegisterDirect<Expander, IPageTransition>( AvaloniaProperty.Register<Expander, IPageTransition>(nameof(ContentTransition));
nameof(ContentTransition),
o => o.ContentTransition,
(o, v) => o.ContentTransition = v);
public static readonly DirectProperty<Expander, ExpandDirection> ExpandDirectionProperty = public static readonly StyledProperty<ExpandDirection> ExpandDirectionProperty =
AvaloniaProperty.RegisterDirect<Expander, ExpandDirection>( AvaloniaProperty.Register<Expander, ExpandDirection>(nameof(ExpandDirection), ExpandDirection.Down);
nameof(ExpandDirection),
o => o.ExpandDirection,
(o, v) => o.ExpandDirection = v,
ExpandDirection.Down);
public static readonly DirectProperty<Expander, bool> IsExpandedProperty = public static readonly DirectProperty<Expander, bool> IsExpandedProperty =
AvaloniaProperty.RegisterDirect<Expander, bool>( AvaloniaProperty.RegisterDirect<Expander, bool>(
@ -33,6 +26,8 @@ namespace Avalonia.Controls
(o, v) => o.IsExpanded = v, (o, v) => o.IsExpanded = v,
defaultBindingMode: Data.BindingMode.TwoWay); defaultBindingMode: Data.BindingMode.TwoWay);
private bool _isExpanded;
static Expander() static Expander()
{ {
PseudoClass<Expander, ExpandDirection>(ExpandDirectionProperty, d => d == ExpandDirection.Down, ":down"); PseudoClass<Expander, ExpandDirection>(ExpandDirectionProperty, d => d == ExpandDirection.Down, ":down");
@ -47,14 +42,14 @@ namespace Avalonia.Controls
public IPageTransition ContentTransition public IPageTransition ContentTransition
{ {
get { return _contentTransition; } get => GetValue(ContentTransitionProperty);
set { SetAndRaise(ContentTransitionProperty, ref _contentTransition, value); } set => SetValue(ContentTransitionProperty, value);
} }
public ExpandDirection ExpandDirection public ExpandDirection ExpandDirection
{ {
get { return _expandDirection; } get => GetValue(ExpandDirectionProperty);
set { SetAndRaise(ExpandDirectionProperty, ref _expandDirection, value); } set => SetValue(ExpandDirectionProperty, value);
} }
public bool IsExpanded public bool IsExpanded
@ -79,9 +74,5 @@ namespace Avalonia.Controls
} }
} }
} }
private IPageTransition _contentTransition;
private ExpandDirection _expandDirection;
private bool _isExpanded;
} }
} }

Loading…
Cancel
Save