XAML-Map-Control/MapControl/WPF/MapPath.WPF.cs

38 lines
1 KiB
C#
Raw Normal View History

2025-02-27 18:46:32 +01:00
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
2026-04-13 17:14:49 +02:00
namespace MapControl;
public partial class MapPath : Shape
{
2026-04-13 17:14:49 +02:00
public static readonly DependencyProperty DataProperty =
DependencyPropertyHelper.AddOwner<MapPath, Geometry>(Path.DataProperty,
(path, oldValue, newValue) => path.DataPropertyChanged(oldValue, newValue));
2026-04-13 17:14:49 +02:00
public Geometry Data
{
get => (Geometry)GetValue(DataProperty);
set => SetValue(DataProperty, value);
}
2026-04-13 17:14:49 +02:00
protected override Geometry DefiningGeometry => Data;
2026-04-13 17:14:49 +02:00
private void DataPropertyChanged(Geometry oldValue, Geometry newValue)
{
// Check if Data is actually a new Geometry.
//
if (newValue != null && !ReferenceEquals(newValue, oldValue))
2022-11-03 20:10:17 +01:00
{
2026-04-13 17:14:49 +02:00
if (newValue.IsFrozen)
{
Data = newValue.Clone(); // DataPropertyChanged called again
}
else
2022-11-03 20:10:17 +01:00
{
2026-04-13 17:14:49 +02:00
UpdateData();
2022-11-03 20:10:17 +01:00
}
}
}
}