/// <summary> /// Handle successful initialization of the resultsLayer /// </summary> private void resultsLayer_Initialized(object sender, EventArgs e) { if (LayerProperties.GetPopupTitleExpressions(resultsLayer) == null) { SetPopupTitleExpression(); } Grid infoWindowGrid = Utils.FindChildOfType <Grid>(popupWindow, 3); // Only display the Keep results on map option of the results layer is not a table if (!infoWindowGrid.Children.Contains(KeepOnMapView) && resultsLayer.LayerInfo.Type != "Table") { infoWindowGrid.Children.Insert(1, KeepOnMapView); } indicator.IsBusy = false; // Get the FeatureLayer's OID field from the LayerInfo string oidField = resultsLayer.LayerInfo.ObjectIdField; // Create a List to hold on to the selected ObjectIds (related records) List <int> list = new List <int>(); //Go through the RelatedRecordsGroup and create a list with the object ids. foreach (var records in queryResult.RelatedRecordsGroup) { foreach (Graphic graphic in records.Value) { // graphic.Geometry.SpatialReference.WKID = map.SpatialReference.WKID; list.Add((int)graphic.Attributes[oidField]); } } // Limit the records displayed to only the ones that match the given object ids. resultsLayer.ObjectIDs = list.ToArray(); // Query is executed and keep on map is still checked (from previous query). Set permanent and temporary layers to null. if (KeepOnMap) { if (permanentLayer != null) { permanentLayer = null; } if (temporaryLayer != null) { temporaryLayer = null; } // Create the permanent layer and add it to the map permanentLayer = CreatePermanentLayer(); map.Layers.Add(permanentLayer); ShowMapContents(); } else // Keep on map is unchecked. { // Create a temp layer first and then wait to see if user clicks checkbox if (temporaryLayer != null && map.Layers.Contains(temporaryLayer)) { map.Layers.Remove(temporaryLayer); temporaryLayer = null; } temporaryLayer = CreateTempLayer(); map.Layers.Add(temporaryLayer); } }