From 039b19f585c093f9f70a45a3eb4871db64f95c72 Mon Sep 17 00:00:00 2001 From: zhangxi <526684540@qq.com> Date: Thu, 24 Aug 2023 17:58:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20polygon/polyline=20load=20fail=20points?= =?UTF-8?q?=20within=20the=20template=EF=BC=9A=20Optimization=20fixed=20co?= =?UTF-8?q?de?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Avalonia.Controls/Shapes/Polygon.cs | 8 +++++++- src/Avalonia.Controls/Shapes/Polyline.cs | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Shapes/Polygon.cs b/src/Avalonia.Controls/Shapes/Polygon.cs index 2d56ced31d..e51e117e33 100644 --- a/src/Avalonia.Controls/Shapes/Polygon.cs +++ b/src/Avalonia.Controls/Shapes/Polygon.cs @@ -1,18 +1,24 @@ using System.Collections.Generic; using Avalonia.Media; +using Avalonia.Data; namespace Avalonia.Controls.Shapes { public class Polygon : Shape { public static readonly StyledProperty> PointsProperty = - AvaloniaProperty.Register>("Points", new Points()); + AvaloniaProperty.Register>("Points"); static Polygon() { AffectsGeometry(PointsProperty); } + public Polygon() + { + SetValue(PointsProperty, new Points(), BindingPriority.Template); + } + public IList Points { get => GetValue(PointsProperty); diff --git a/src/Avalonia.Controls/Shapes/Polyline.cs b/src/Avalonia.Controls/Shapes/Polyline.cs index 63c37780c5..dc28b7b34a 100644 --- a/src/Avalonia.Controls/Shapes/Polyline.cs +++ b/src/Avalonia.Controls/Shapes/Polyline.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Avalonia.Media; +using Avalonia.Data; namespace Avalonia.Controls.Shapes { @@ -14,6 +15,11 @@ namespace Avalonia.Controls.Shapes AffectsGeometry(PointsProperty); } + public Polyline() + { + SetValue(PointsProperty, new Points(), BindingPriority.Template); + } + public IList Points { get => GetValue(PointsProperty);