private async void OnOpenCloseButtonClicked(object sender, RoutedEventArgs e) { DockMeasurementDetail measurementDetail = (DockMeasurementDetail)DataContext; MeasurementPoint measurementPoint = measurementDetail?.MeasurementPoint; Measurement measurement = measurementPoint?.Measurement; if (measurementPoint != null) { if (measurementPoint.Open) { measurementPoint.ClosePoint(); if (!measurement.IsPointMeasurement) { measurement.EnableMeasurementSeries(); } await measurement.MeasurementPointUpdatedAsync(measurementPoint.PointId); if (measurement.IsPointMeasurement) { MapView mapView = MapView.Active; Geometry geometry = await mapView.GetCurrentSketchAsync(); VectorLayer layer = measurement.VectorLayer; long? uid = measurement.ObjectId; if (geometry != null && uid == null && layer != null) { await layer.AddFeatureAsync(geometry); } else if (uid != null && layer != null) { MapPoint mapPoint = measurementPoint.Point; await layer.UpdateFeatureAsync((long)uid, mapPoint); } } measurementDetail.SelectedObservation = null; } else { if (measurement.IsPointMeasurement) { measurement.OpenMeasurement(); } else { measurement.DisableMeasurementSeries(); } measurementPoint.OpenPoint(); } } }