From ed6251fbe8eba23bf80da73f3758d3574fdc06a6 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 16 May 2019 09:19:40 +0200 Subject: [PATCH] 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 --- src/Avalonia.Controls/Expander.cs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/Avalonia.Controls/Expander.cs b/src/Avalonia.Controls/Expander.cs index f0ba2b5578..1fa9798784 100644 --- a/src/Avalonia.Controls/Expander.cs +++ b/src/Avalonia.Controls/Expander.cs @@ -13,18 +13,11 @@ namespace Avalonia.Controls public class Expander : HeaderedContentControl { - public static readonly DirectProperty ContentTransitionProperty = - AvaloniaProperty.RegisterDirect( - nameof(ContentTransition), - o => o.ContentTransition, - (o, v) => o.ContentTransition = v); + public static readonly StyledProperty ContentTransitionProperty = + AvaloniaProperty.Register(nameof(ContentTransition)); - public static readonly DirectProperty ExpandDirectionProperty = - AvaloniaProperty.RegisterDirect( - nameof(ExpandDirection), - o => o.ExpandDirection, - (o, v) => o.ExpandDirection = v, - ExpandDirection.Down); + public static readonly StyledProperty ExpandDirectionProperty = + AvaloniaProperty.Register(nameof(ExpandDirection), ExpandDirection.Down); public static readonly DirectProperty IsExpandedProperty = AvaloniaProperty.RegisterDirect( @@ -33,6 +26,8 @@ namespace Avalonia.Controls (o, v) => o.IsExpanded = v, defaultBindingMode: Data.BindingMode.TwoWay); + private bool _isExpanded; + static Expander() { PseudoClass(ExpandDirectionProperty, d => d == ExpandDirection.Down, ":down"); @@ -47,14 +42,14 @@ namespace Avalonia.Controls public IPageTransition ContentTransition { - get { return _contentTransition; } - set { SetAndRaise(ContentTransitionProperty, ref _contentTransition, value); } + get => GetValue(ContentTransitionProperty); + set => SetValue(ContentTransitionProperty, value); } public ExpandDirection ExpandDirection { - get { return _expandDirection; } - set { SetAndRaise(ExpandDirectionProperty, ref _expandDirection, value); } + get => GetValue(ExpandDirectionProperty); + set => SetValue(ExpandDirectionProperty, value); } public bool IsExpanded @@ -79,9 +74,5 @@ namespace Avalonia.Controls } } } - - private IPageTransition _contentTransition; - private ExpandDirection _expandDirection; - private bool _isExpanded; } }