diff --git a/src/Avalonia.Visuals/Media/PathFigure.cs b/src/Avalonia.Visuals/Media/PathFigure.cs
index 0c4cc592af..2f8d11b06e 100644
--- a/src/Avalonia.Visuals/Media/PathFigure.cs
+++ b/src/Avalonia.Visuals/Media/PathFigure.cs
@@ -1,5 +1,5 @@
+#nullable enable
using System;
-using System.ComponentModel;
using Avalonia.Collections;
using Avalonia.Metadata;
@@ -11,29 +11,35 @@ namespace Avalonia.Media
/// Defines the property.
///
public static readonly StyledProperty IsClosedProperty
- = AvaloniaProperty.Register(nameof(IsClosed), true);
+ = AvaloniaProperty.Register(nameof(IsClosed), true);
+
///
/// Defines the property.
///
public static readonly StyledProperty IsFilledProperty
- = AvaloniaProperty.Register(nameof(IsFilled), true);
+ = AvaloniaProperty.Register(nameof(IsFilled), true);
+
///
/// Defines the property.
///
public static readonly DirectProperty SegmentsProperty
- = AvaloniaProperty.RegisterDirect(nameof(Segments), f => f.Segments, (f, s) => f.Segments = s);
+ = AvaloniaProperty.RegisterDirect(nameof(Segments), f => f.Segments,
+ (f, s) => f.Segments = s);
+
///
/// Defines the property.
///
public static readonly StyledProperty StartPointProperty
- = AvaloniaProperty.Register(nameof(StartPoint));
+ = AvaloniaProperty.Register(nameof(StartPoint));
+
+ internal event EventHandler? SegmentsInvalidated;
- internal event EventHandler SegmentsInvalidated;
+ private PathSegments? _segments;
- private IDisposable _segmentsDisposable;
+ private IDisposable? _segmentsDisposable;
+
+ private IDisposable? _segmentsPropertiesDisposable;
- private IDisposable _segmentsPropertiesDisposable;
-
///
/// Initializes a new instance of the class.
///
@@ -57,7 +63,7 @@ namespace Avalonia.Media
_ => InvalidateSegments(),
_ => InvalidateSegments(),
InvalidateSegments);
-
+
_segmentsPropertiesDisposable = _segments?.TrackItemPropertyChanged(_ => InvalidateSegments());
}
@@ -127,8 +133,6 @@ namespace Avalonia.Media
ctx.EndFigure(IsClosed);
}
- private PathSegments _segments;
-
public override string ToString()
=> $"M {StartPoint} {string.Join(" ", _segments)}{(IsClosed ? "Z" : "")}";
}