DependencyPropertyHelper

This commit is contained in:
ClemensFischer 2024-05-23 18:22:52 +02:00
parent 8e82e0bcbd
commit bc12b388de
20 changed files with 90 additions and 79 deletions

View file

@ -11,9 +11,9 @@ namespace MapControl
public static StyledProperty<TValue> Register<TOwner, TValue>( public static StyledProperty<TValue> Register<TOwner, TValue>(
string name, string name,
TValue defaultValue = default, TValue defaultValue = default,
bool bindTwoWayByDefault = false,
Action<TOwner, TValue, TValue> changed = null, Action<TOwner, TValue, TValue> changed = null,
Func<TOwner, TValue, TValue> coerce = null) Func<TOwner, TValue, TValue> coerce = null,
bool bindTwoWayByDefault = false)
where TOwner : AvaloniaObject where TOwner : AvaloniaObject
{ {
var property = AvaloniaProperty.Register<TOwner, TValue>(name, defaultValue, false, var property = AvaloniaProperty.Register<TOwner, TValue>(name, defaultValue, false,

View file

@ -18,44 +18,50 @@ namespace MapControl
DependencyPropertyHelper.Register<MapBase, Easing>(nameof(AnimationEasing), new QuadraticEaseOut()); DependencyPropertyHelper.Register<MapBase, Easing>(nameof(AnimationEasing), new QuadraticEaseOut());
public static readonly StyledProperty<Location> CenterProperty = public static readonly StyledProperty<Location> CenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(), true, DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(),
(map, oldValue, newValue) => map.CenterPropertyChanged(newValue), (map, oldValue, newValue) => map.CenterPropertyChanged(newValue),
(map, value) => map.CoerceCenterProperty(value)); (map, value) => map.CoerceCenterProperty(value),
true);
public static readonly StyledProperty<Location> TargetCenterProperty = public static readonly StyledProperty<Location> TargetCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(), true, DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(),
async (map, oldValue, newValue) => await map.TargetCenterPropertyChanged(newValue), async (map, oldValue, newValue) => await map.TargetCenterPropertyChanged(newValue),
(map, value) => map.CoerceCenterProperty(value)); (map, value) => map.CoerceCenterProperty(value),
true);
public static readonly StyledProperty<double> MinZoomLevelProperty = public static readonly StyledProperty<double> MinZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(MinZoomLevel), 1d, false, DependencyPropertyHelper.Register<MapBase, double>(nameof(MinZoomLevel), 1d,
(map, oldValue, newValue) => map.MinZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.MinZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceMinZoomLevelProperty(value)); (map, value) => map.CoerceMinZoomLevelProperty(value));
public static readonly StyledProperty<double> MaxZoomLevelProperty = public static readonly StyledProperty<double> MaxZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(MaxZoomLevel), 20d, false, DependencyPropertyHelper.Register<MapBase, double>(nameof(MaxZoomLevel), 20d,
(map, oldValue, newValue) => map.MaxZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.MaxZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceMaxZoomLevelProperty(value)); (map, value) => map.CoerceMaxZoomLevelProperty(value));
public static readonly StyledProperty<double> ZoomLevelProperty = public static readonly StyledProperty<double> ZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(ZoomLevel), 1d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(ZoomLevel), 1d,
(map, oldValue, newValue) => map.ZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.ZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceZoomLevelProperty(value)); (map, value) => map.CoerceZoomLevelProperty(value),
true);
public static readonly StyledProperty<double> TargetZoomLevelProperty = public static readonly StyledProperty<double> TargetZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d,
async (map, oldValue, newValue) => await map.TargetZoomLevelPropertyChanged(newValue), async (map, oldValue, newValue) => await map.TargetZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceZoomLevelProperty(value)); (map, value) => map.CoerceZoomLevelProperty(value),
true);
public static readonly StyledProperty<double> HeadingProperty = public static readonly StyledProperty<double> HeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(Heading), 0d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(Heading), 0d,
(map, oldValue, newValue) => map.HeadingPropertyChanged(newValue), (map, oldValue, newValue) => map.HeadingPropertyChanged(newValue),
(map, value) => map.CoerceHeadingProperty(value)); (map, value) => map.CoerceHeadingProperty(value),
true);
public static readonly StyledProperty<double> TargetHeadingProperty = public static readonly StyledProperty<double> TargetHeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d,
async (map, oldValue, newValue) => await map.TargetHeadingPropertyChanged(newValue), async (map, oldValue, newValue) => await map.TargetHeadingPropertyChanged(newValue),
(map, value) => map.CoerceHeadingProperty(value)); (map, value) => map.CoerceHeadingProperty(value),
true);
public static readonly DirectProperty<MapBase, double> ViewScaleProperty = public static readonly DirectProperty<MapBase, double> ViewScaleProperty =
AvaloniaProperty.RegisterDirect<MapBase, double>(nameof(ViewScale), map => map.ViewTransform.Scale); AvaloniaProperty.RegisterDirect<MapBase, double>(nameof(ViewScale), map => map.ViewTransform.Scale);

View file

@ -52,7 +52,7 @@ namespace MapControl
private static string QueryString(ushort tag) => $"/ifd/{{ushort={tag}}}"; private static string QueryString(ushort tag) => $"/ifd/{{ushort={tag}}}";
public static readonly DependencyProperty SourcePathProperty = public static readonly DependencyProperty SourcePathProperty =
DependencyPropertyHelper.Register<GeoImage, string>(nameof(SourcePath), null, false, DependencyPropertyHelper.Register<GeoImage, string>(nameof(SourcePath), null,
async (image, oldValue, newValue) => await image.SourcePathPropertyChanged(newValue)); async (image, oldValue, newValue) => await image.SourcePathPropertyChanged(newValue));
public GeoImage() public GeoImage()

View file

@ -62,7 +62,7 @@ namespace MapControl
} }
public static readonly DependencyProperty SourcePathProperty = public static readonly DependencyProperty SourcePathProperty =
DependencyPropertyHelper.Register<GroundOverlay, string>(nameof(SourcePath), null, false, DependencyPropertyHelper.Register<GroundOverlay, string>(nameof(SourcePath), null,
async (overlay, oldValue, newValue) => await overlay.SourcePathPropertyChanged(newValue)); async (overlay, oldValue, newValue) => await overlay.SourcePathPropertyChanged(newValue));
public string SourcePath public string SourcePath

View file

@ -46,15 +46,15 @@ namespace MapControl
DependencyPropertyHelper.Register<MapBase, TimeSpan>(nameof(AnimationDuration), TimeSpan.FromSeconds(0.3)); DependencyPropertyHelper.Register<MapBase, TimeSpan>(nameof(AnimationDuration), TimeSpan.FromSeconds(0.3));
public static readonly DependencyProperty MapLayerProperty = public static readonly DependencyProperty MapLayerProperty =
DependencyPropertyHelper.Register<MapBase, UIElement>(nameof(MapLayer), null, false, DependencyPropertyHelper.Register<MapBase, UIElement>(nameof(MapLayer), null,
(map, oldValue, newValue) => map.MapLayerPropertyChanged(oldValue, newValue)); (map, oldValue, newValue) => map.MapLayerPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty MapProjectionProperty = public static readonly DependencyProperty MapProjectionProperty =
DependencyPropertyHelper.Register<MapBase, MapProjection>(nameof(MapProjection), new WebMercatorProjection(), false, DependencyPropertyHelper.Register<MapBase, MapProjection>(nameof(MapProjection), new WebMercatorProjection(),
(map, oldValue, newValue) => map.MapProjectionPropertyChanged(newValue)); (map, oldValue, newValue) => map.MapProjectionPropertyChanged(newValue));
public static readonly DependencyProperty ProjectionCenterProperty = public static readonly DependencyProperty ProjectionCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(ProjectionCenter), null, false, DependencyPropertyHelper.Register<MapBase, Location>(nameof(ProjectionCenter), null,
(map, oldValue, newValue) => map.ProjectionCenterPropertyChanged()); (map, oldValue, newValue) => map.ProjectionCenterPropertyChanged());
private Location transformCenter; private Location transformCenter;

View file

@ -44,7 +44,7 @@ namespace MapControl
public static readonly DependencyProperty UpdateIntervalProperty = public static readonly DependencyProperty UpdateIntervalProperty =
DependencyPropertyHelper.Register<MapImageLayer, TimeSpan>(nameof(UpdateInterval), TimeSpan.FromSeconds(0.2), DependencyPropertyHelper.Register<MapImageLayer, TimeSpan>(nameof(UpdateInterval), TimeSpan.FromSeconds(0.2),
false, (layer, oldValue, newValue) => layer.updateTimer.Interval = newValue); (layer, oldValue, newValue) => layer.updateTimer.Interval = newValue);
public static readonly DependencyProperty UpdateWhileViewportChangingProperty = public static readonly DependencyProperty UpdateWhileViewportChangingProperty =
DependencyPropertyHelper.Register<MapImageLayer, bool>(nameof(UpdateWhileViewportChanging)); DependencyPropertyHelper.Register<MapImageLayer, bool>(nameof(UpdateWhileViewportChanging));

View file

@ -24,7 +24,7 @@ namespace MapControl
public partial class MapPath : IMapElement public partial class MapPath : IMapElement
{ {
public static readonly DependencyProperty LocationProperty = public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null, false, DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null,
(path, oldValue, newValue) => path.UpdateData()); (path, oldValue, newValue) => path.UpdateData());
private MapBase parentMap; private MapBase parentMap;

View file

@ -22,11 +22,11 @@ namespace MapControl
public class MapPolygon : MapPath public class MapPolygon : MapPath
{ {
public static readonly DependencyProperty LocationsProperty = public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null, false, DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null,
(polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue)); (polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty = public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd, false, DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd,
(polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue); (polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue);
/// <summary> /// <summary>

View file

@ -22,11 +22,11 @@ namespace MapControl
public class MapPolyline : MapPath public class MapPolyline : MapPath
{ {
public static readonly DependencyProperty LocationsProperty = public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null, false, DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null,
(polyline, oldValue, newValue) => polyline.DataCollectionPropertyChanged(oldValue, newValue)); (polyline, oldValue, newValue) => polyline.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty = public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd, false, DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd,
(polyline, oldValue, newValue) => ((PathGeometry)polyline.Data).FillRule = newValue); (polyline, oldValue, newValue) => ((PathGeometry)polyline.Data).FillRule = newValue);
/// <summary> /// <summary>

View file

@ -31,7 +31,7 @@ namespace MapControl
public abstract partial class MapTileLayerBase : Panel, IMapLayer public abstract partial class MapTileLayerBase : Panel, IMapLayer
{ {
public static readonly DependencyProperty TileSourceProperty = public static readonly DependencyProperty TileSourceProperty =
DependencyPropertyHelper.Register<MapTileLayerBase, TileSource>(nameof(TileSource), null, false, DependencyPropertyHelper.Register<MapTileLayerBase, TileSource>(nameof(TileSource), null,
async (layer, oldValue, newValue) => await layer.Update(true)); async (layer, oldValue, newValue) => await layer.Update(true));
public static readonly DependencyProperty SourceNameProperty = public static readonly DependencyProperty SourceNameProperty =

View file

@ -30,11 +30,15 @@ namespace MapControl
public partial class WmsImageLayer : MapImageLayer public partial class WmsImageLayer : MapImageLayer
{ {
public static readonly DependencyProperty ServiceUriProperty = public static readonly DependencyProperty ServiceUriProperty =
DependencyPropertyHelper.Register<WmsImageLayer, Uri>(nameof(ServiceUri), null, false, DependencyPropertyHelper.Register<WmsImageLayer, Uri>(nameof(ServiceUri), null,
async (layer, oldValue, newValue) => await layer.UpdateImageAsync());
public static readonly DependencyProperty WmsStylesProperty =
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsStyles), string.Empty,
async (layer, oldValue, newValue) => await layer.UpdateImageAsync()); async (layer, oldValue, newValue) => await layer.UpdateImageAsync());
public static readonly DependencyProperty WmsLayersProperty = public static readonly DependencyProperty WmsLayersProperty =
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsLayers), null, false, DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsLayers), null,
async (layer, oldValue, newValue) => async (layer, oldValue, newValue) =>
{ {
// Ignore property change from GetImageAsync when Layers was null. // Ignore property change from GetImageAsync when Layers was null.
@ -45,10 +49,6 @@ namespace MapControl
} }
}); });
public static readonly DependencyProperty WmsStylesProperty =
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsStyles), string.Empty, false,
async (layer, oldValue, newValue) => await layer.UpdateImageAsync());
/// <summary> /// <summary>
/// The base request URL. /// The base request URL.
/// </summary> /// </summary>
@ -58,15 +58,6 @@ namespace MapControl
set => SetValue(ServiceUriProperty, value); set => SetValue(ServiceUriProperty, value);
} }
/// <summary>
/// Comma-separated sequence of WMS Layer names to be displayed. If not set, the first Layer is displayed.
/// </summary>
public string WmsLayers
{
get => (string)GetValue(WmsLayersProperty);
set => SetValue(WmsLayersProperty, value);
}
/// <summary> /// <summary>
/// Comma-separated sequence of requested WMS Styles. Default is an empty string. /// Comma-separated sequence of requested WMS Styles. Default is an empty string.
/// </summary> /// </summary>
@ -76,6 +67,15 @@ namespace MapControl
set => SetValue(WmsStylesProperty, value); set => SetValue(WmsStylesProperty, value);
} }
/// <summary>
/// Comma-separated sequence of WMS Layer names to be displayed. If not set, the first Layer is displayed.
/// </summary>
public string WmsLayers
{
get => (string)GetValue(WmsLayersProperty);
set => SetValue(WmsLayersProperty, value);
}
/// <summary> /// <summary>
/// Gets a list of all layer names returned by a GetCapabilities response. /// Gets a list of all layer names returned by a GetCapabilities response.
/// </summary> /// </summary>

View file

@ -28,7 +28,7 @@ namespace MapControl
public class WmtsTileLayer : MapTileLayerBase public class WmtsTileLayer : MapTileLayerBase
{ {
public static readonly DependencyProperty CapabilitiesUriProperty = public static readonly DependencyProperty CapabilitiesUriProperty =
DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri), null, false, DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri), null,
(layer, oldValue, newValue) => layer.TileMatrixSets.Clear()); (layer, oldValue, newValue) => layer.TileMatrixSets.Clear());
public static readonly DependencyProperty LayerProperty = public static readonly DependencyProperty LayerProperty =

View file

@ -21,9 +21,9 @@ namespace MapControl
public static DependencyProperty Register<TOwner, TValue>( public static DependencyProperty Register<TOwner, TValue>(
string name, string name,
TValue defaultValue = default, TValue defaultValue = default,
bool bindTwoWayByDefault = false,
Action<TOwner, TValue, TValue> changed = null, Action<TOwner, TValue, TValue> changed = null,
Func<TOwner, TValue, TValue> coerce = null) Func<TOwner, TValue, TValue> coerce = null,
bool bindTwoWayByDefault = false)
where TOwner : DependencyObject where TOwner : DependencyObject
{ {
var metadata = new FrameworkPropertyMetadata var metadata = new FrameworkPropertyMetadata

View file

@ -14,44 +14,50 @@ namespace MapControl
new QuadraticEase { EasingMode = EasingMode.EaseOut }); new QuadraticEase { EasingMode = EasingMode.EaseOut });
public static readonly DependencyProperty CenterProperty = public static readonly DependencyProperty CenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(), true, DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(),
(map, oldValue, newValue) => map.CenterPropertyChanged(newValue), (map, oldValue, newValue) => map.CenterPropertyChanged(newValue),
(map, value) => map.CoerceCenterProperty(value)); (map, value) => map.CoerceCenterProperty(value),
true);
public static readonly DependencyProperty TargetCenterProperty = public static readonly DependencyProperty TargetCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(), true, DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(),
(map, oldValue, newValue) => map.TargetCenterPropertyChanged(newValue), (map, oldValue, newValue) => map.TargetCenterPropertyChanged(newValue),
(map, value) => map.CoerceCenterProperty(value)); (map, value) => map.CoerceCenterProperty(value),
true);
public static readonly DependencyProperty MinZoomLevelProperty = public static readonly DependencyProperty MinZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(MinZoomLevel), 1d, false, DependencyPropertyHelper.Register<MapBase, double>(nameof(MinZoomLevel), 1d,
(map, oldValue, newValue) => map.MinZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.MinZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceMinZoomLevelProperty(value)); (map, value) => map.CoerceMinZoomLevelProperty(value));
public static readonly DependencyProperty MaxZoomLevelProperty = public static readonly DependencyProperty MaxZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(MaxZoomLevel), 20d, false, DependencyPropertyHelper.Register<MapBase, double>(nameof(MaxZoomLevel), 20d,
(map, oldValue, newValue) => map.MaxZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.MaxZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceMaxZoomLevelProperty(value)); (map, value) => map.CoerceMaxZoomLevelProperty(value));
public static readonly DependencyProperty ZoomLevelProperty = public static readonly DependencyProperty ZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(ZoomLevel), 1d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(ZoomLevel), 1d,
(map, oldValue, newValue) => map.ZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.ZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceZoomLevelProperty(value)); (map, value) => map.CoerceZoomLevelProperty(value),
true);
public static readonly DependencyProperty TargetZoomLevelProperty = public static readonly DependencyProperty TargetZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d,
(map, oldValue, newValue) => map.TargetZoomLevelPropertyChanged(newValue), (map, oldValue, newValue) => map.TargetZoomLevelPropertyChanged(newValue),
(map, value) => map.CoerceZoomLevelProperty(value)); (map, value) => map.CoerceZoomLevelProperty(value),
true);
public static readonly DependencyProperty HeadingProperty = public static readonly DependencyProperty HeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(Heading), 0d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(Heading), 0d,
(map, oldValue, newValue) => map.HeadingPropertyChanged(newValue), (map, oldValue, newValue) => map.HeadingPropertyChanged(newValue),
(map, value) => map.CoerceHeadingProperty(value)); (map, value) => map.CoerceHeadingProperty(value),
true);
public static readonly DependencyProperty TargetHeadingProperty = public static readonly DependencyProperty TargetHeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d,
(map, oldValue, newValue) => map.TargetHeadingPropertyChanged(newValue), (map, oldValue, newValue) => map.TargetHeadingPropertyChanged(newValue),
(map, value) => map.CoerceHeadingProperty(value)); (map, value) => map.CoerceHeadingProperty(value),
true);
private static readonly DependencyPropertyKey ViewScalePropertyKey = private static readonly DependencyPropertyKey ViewScalePropertyKey =
DependencyPropertyHelper.RegisterReadOnly<MapBase, double>(nameof(ViewScale), 0d); DependencyPropertyHelper.RegisterReadOnly<MapBase, double>(nameof(ViewScale), 0d);

View file

@ -19,11 +19,11 @@ namespace MapControl
public class MapMultiPolygon : MapPath public class MapMultiPolygon : MapPath
{ {
public static readonly DependencyProperty PolygonsProperty = public static readonly DependencyProperty PolygonsProperty =
DependencyPropertyHelper.Register<MapMultiPolygon, IEnumerable<IEnumerable<Location>>>(nameof(Polygons), null, false, DependencyPropertyHelper.Register<MapMultiPolygon, IEnumerable<IEnumerable<Location>>>(nameof(Polygons), null,
(polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue)); (polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty = public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapMultiPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd, false, DependencyPropertyHelper.Register<MapMultiPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd,
(polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue); (polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue);
/// <summary> /// <summary>

View file

@ -18,7 +18,6 @@ namespace MapControl
public static DependencyProperty Register<TOwner, TValue>( public static DependencyProperty Register<TOwner, TValue>(
string name, string name,
TValue defaultValue = default, TValue defaultValue = default,
bool bindTwoWayByDefault = false, // unused in WinUI/UWP
Action<TOwner, TValue, TValue> changed = null) Action<TOwner, TValue, TValue> changed = null)
where TOwner : DependencyObject where TOwner : DependencyObject
{ {

View file

@ -23,43 +23,43 @@ namespace MapControl
new QuadraticEase { EasingMode = EasingMode.EaseOut }); new QuadraticEase { EasingMode = EasingMode.EaseOut });
public static readonly DependencyProperty CenterProperty = public static readonly DependencyProperty CenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(), true, DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(),
(map, oldValue, newValue) => map.CenterPropertyChanged(newValue)); (map, oldValue, newValue) => map.CenterPropertyChanged(newValue));
public static readonly DependencyProperty TargetCenterProperty = public static readonly DependencyProperty TargetCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(), true, DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(),
(map, oldValue, newValue) => map.TargetCenterPropertyChanged(newValue)); (map, oldValue, newValue) => map.TargetCenterPropertyChanged(newValue));
public static readonly DependencyProperty MinZoomLevelProperty = public static readonly DependencyProperty MinZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(MinZoomLevel), 1d, false, DependencyPropertyHelper.Register<MapBase, double>(nameof(MinZoomLevel), 1d,
(map, oldValue, newValue) => map.MinZoomLevelPropertyChanged(newValue)); (map, oldValue, newValue) => map.MinZoomLevelPropertyChanged(newValue));
public static readonly DependencyProperty MaxZoomLevelProperty = public static readonly DependencyProperty MaxZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(MaxZoomLevel), 20d, false, DependencyPropertyHelper.Register<MapBase, double>(nameof(MaxZoomLevel), 20d,
(map, oldValue, newValue) => map.MaxZoomLevelPropertyChanged(newValue)); (map, oldValue, newValue) => map.MaxZoomLevelPropertyChanged(newValue));
public static readonly DependencyProperty ZoomLevelProperty = public static readonly DependencyProperty ZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(ZoomLevel), 1d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(ZoomLevel), 1d,
(map, oldValue, newValue) => map.ZoomLevelPropertyChanged(newValue)); (map, oldValue, newValue) => map.ZoomLevelPropertyChanged(newValue));
public static readonly DependencyProperty TargetZoomLevelProperty = public static readonly DependencyProperty TargetZoomLevelProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetZoomLevel), 1d,
(map, oldValue, newValue) => map.TargetZoomLevelPropertyChanged(newValue)); (map, oldValue, newValue) => map.TargetZoomLevelPropertyChanged(newValue));
public static readonly DependencyProperty HeadingProperty = public static readonly DependencyProperty HeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(Heading), 0d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(Heading), 0d,
(map, oldValue, newValue) => map.HeadingPropertyChanged(newValue)); (map, oldValue, newValue) => map.HeadingPropertyChanged(newValue));
public static readonly DependencyProperty TargetHeadingProperty = public static readonly DependencyProperty TargetHeadingProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d, true, DependencyPropertyHelper.Register<MapBase, double>(nameof(TargetHeading), 0d,
(map, oldValue, newValue) => map.TargetHeadingPropertyChanged(newValue)); (map, oldValue, newValue) => map.TargetHeadingPropertyChanged(newValue));
public static readonly DependencyProperty ViewScaleProperty = public static readonly DependencyProperty ViewScaleProperty =
DependencyPropertyHelper.Register<MapBase, double>(nameof(ViewScale), 0d); DependencyPropertyHelper.Register<MapBase, double>(nameof(ViewScale), 0d);
private static readonly DependencyProperty AnimatedCenterProperty = private static readonly DependencyProperty AnimatedCenterProperty =
DependencyPropertyHelper.Register<MapBase, Windows.Foundation.Point>(nameof(AnimatedCenter), DependencyPropertyHelper.Register<MapBase, Windows.Foundation.Point>(nameof(AnimatedCenter), new Windows.Foundation.Point(),
new Windows.Foundation.Point(), false, (map, oldValue, newValue) => map.Center = new Location(newValue.Y, newValue.X)); (map, oldValue, newValue) => map.Center = new Location(newValue.Y, newValue.X));
private Windows.Foundation.Point AnimatedCenter => (Windows.Foundation.Point)GetValue(AnimatedCenterProperty); private Windows.Foundation.Point AnimatedCenter => (Windows.Foundation.Point)GetValue(AnimatedCenterProperty);

View file

@ -18,11 +18,11 @@ namespace MapControl
public class MapContentControl : ContentControl public class MapContentControl : ContentControl
{ {
public static readonly DependencyProperty AutoCollapseProperty = public static readonly DependencyProperty AutoCollapseProperty =
DependencyPropertyHelper.Register<MapContentControl, bool>(nameof(AutoCollapse), false, false, DependencyPropertyHelper.Register<MapContentControl, bool>(nameof(AutoCollapse), false,
(control, oldValue, newValue) => MapPanel.SetAutoCollapse(control, newValue)); (control, oldValue, newValue) => MapPanel.SetAutoCollapse(control, newValue));
public static readonly DependencyProperty LocationProperty = public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapContentControl, Location>(nameof(Location), null, false, DependencyPropertyHelper.Register<MapContentControl, Location>(nameof(Location), null,
(control, oldValue, newValue) => MapPanel.SetLocation(control, newValue)); (control, oldValue, newValue) => MapPanel.SetLocation(control, newValue));
public MapContentControl() public MapContentControl()

View file

@ -18,11 +18,11 @@ namespace MapControl
public partial class MapItem public partial class MapItem
{ {
public static readonly DependencyProperty AutoCollapseProperty = public static readonly DependencyProperty AutoCollapseProperty =
DependencyPropertyHelper.Register<MapItem, bool>(nameof(AutoCollapse), false, false, DependencyPropertyHelper.Register<MapItem, bool>(nameof(AutoCollapse), false,
(item, oldValue, newValue) => MapPanel.SetAutoCollapse(item, newValue)); (item, oldValue, newValue) => MapPanel.SetAutoCollapse(item, newValue));
public static readonly DependencyProperty LocationProperty = public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapItem, Location>(nameof(Location), null, false, DependencyPropertyHelper.Register<MapItem, Location>(nameof(Location), null,
(item, oldValue, newValue) => item.LocationPropertyChanged(newValue)); (item, oldValue, newValue) => item.LocationPropertyChanged(newValue));
private void LocationPropertyChanged(Location location) private void LocationPropertyChanged(Location location)

View file

@ -25,11 +25,11 @@ namespace MapControl
public partial class PushpinBorder : UserControl public partial class PushpinBorder : UserControl
{ {
public static readonly DependencyProperty ArrowSizeProperty = public static readonly DependencyProperty ArrowSizeProperty =
DependencyPropertyHelper.Register<PushpinBorder, Size>(nameof(ArrowSize), new Size(10d, 20d), false, DependencyPropertyHelper.Register<PushpinBorder, Size>(nameof(ArrowSize), new Size(10d, 20d),
(border, oldValue, newValue) => border.SetBorderMargin()); (border, oldValue, newValue) => border.SetBorderMargin());
public static readonly DependencyProperty BorderWidthProperty = public static readonly DependencyProperty BorderWidthProperty =
DependencyPropertyHelper.Register<PushpinBorder, double>(nameof(BorderWidth), 0d, false, DependencyPropertyHelper.Register<PushpinBorder, double>(nameof(BorderWidth), 0d,
(border, oldValue, newValue) => border.SetBorderMargin()); (border, oldValue, newValue) => border.SetBorderMargin());
private readonly Border border = new Border(); private readonly Border border = new Border();