private static void OnDynamicShapeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Shape dynamicShape = e.NewValue as Shape; MapGraphicItemsSourceBehavior mapGraphicItemsSourceBehavior = (MapGraphicItemsSourceBehavior)d; if (mapGraphicItemsSourceBehavior != null && mapGraphicItemsSourceBehavior.AssociatedObject != null) { Graphic graphic = null; var graphicsLayer = mapGraphicItemsSourceBehavior.AssociatedObject.Layers["Shapes"] as GraphicsLayer; if (dynamicShape != null) { if (graphicsLayer != null) { graphic = graphicsLayer.Graphics.FirstOrDefault(p => p.Geometry == dynamicShape.Geometry); if (graphic != null) { bool isValid = mapGraphicItemsSourceBehavior.IsValidGraphicChecked(graphic); if (isValid) { mapGraphicItemsSourceBehavior.SelectByGraphic(graphic); } } } } } }
private static void OnEditGeometryActionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MapGraphicItemsSourceBehavior me = (MapGraphicItemsSourceBehavior)d; if (me != null) { if (me.EditGeometryAction == EditGeometry.Action.EditCanceled) { if (me.ItemsSource != null) { me.ItemsSource.Remove(me.EditShape); } me.EditShape = null; me.EditGeometry.IsEnabled = false; me.ClearSelection(); me.EditGeometry.StopEdit(); } else if (me.EditGeometryAction == EditGeometry.Action.EditCompleted) { me.EditGeometry.StopEdit(); } } }