From 60ba488219b195b493bde077448b0ab82cd26f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9B=E5=B0=98=E7=A9=BA=E5=BF=A7?= Date: Wed, 13 Nov 2024 06:14:08 +0800 Subject: [PATCH] fix:Go to AspectRatioLayout demo and go to another and go back, the demo will crash. --- .../AspectRatioLayout/AspectRatioLayout.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Ursa/Controls/AspectRatioLayout/AspectRatioLayout.cs b/src/Ursa/Controls/AspectRatioLayout/AspectRatioLayout.cs index e1f7da5..86a372f 100644 --- a/src/Ursa/Controls/AspectRatioLayout/AspectRatioLayout.cs +++ b/src/Ursa/Controls/AspectRatioLayout/AspectRatioLayout.cs @@ -11,7 +11,7 @@ public class AspectRatioLayout : TransitioningContentControl { public static readonly StyledProperty> ItemsProperty = AvaloniaProperty.Register>( - nameof(Items), new List()); + nameof(Items)); public static readonly StyledProperty AspectRatioChangeAmbiguityProperty = AvaloniaProperty.Register( @@ -21,12 +21,6 @@ public class AspectRatioLayout : TransitioningContentControl AvaloniaProperty.Register( nameof(CurrentAspectRatioMode)); - public AspectRatioMode CurrentAspectRatioMode - { - get => GetValue(CurrentAspectRatioModeProperty); - set => SetValue(CurrentAspectRatioModeProperty, value); - } - private readonly Queue _history = new(); static AspectRatioLayout() @@ -40,6 +34,17 @@ public class AspectRatioLayout : TransitioningContentControl PageTransitionProperty.OverrideDefaultValue(pCrossFade); } + public AspectRatioLayout() + { + Items = new List(); + } + + public AspectRatioMode CurrentAspectRatioMode + { + get => GetValue(CurrentAspectRatioModeProperty); + set => SetValue(CurrentAspectRatioModeProperty, value); + } + protected override Type StyleKeyOverride => typeof(TransitioningContentControl); [Content]