static private CreateMapOverlay ( object content, System.Windows.DataTemplate contentTemplate ) : MapOverlay | ||
content | object | Content of the MapOverlay |
contentTemplate | System.Windows.DataTemplate | Template to be used in the MapOverlay |
return | MapOverlay |
/// <summary> /// Takes the target object and create the corresponding MapLayer that will be used /// to host in MapOverlays all the items provided. /// </summary> /// <param name="obj">Object from the source collection to be processed</param> /// <returns>The MapLayer that will be used to host the items from the source</returns> /// <remarks> /// It only supports two types of objects 1) MapItemsControl or 2) anything else. /// For MapItemsControls, the creation of the MapOverlays will be deferred to the MapItemsControl /// </remarks> private static MapLayer GetMapLayerForObject(object obj) { MapLayer mapLayer; MapItemsControl mapItemsControl; // Only to types of objects supported per se. // 1) MapItemsControl // 2) Everything else mapItemsControl = obj as MapItemsControl; if (mapItemsControl != null) { // MapsItemsControl does their own control of creation of MapOverlays // because by the time we are here, items may be there already. // For that reason, we only bring the MapLayer an add it. mapLayer = mapItemsControl.MapLayer; Debug.Assert(mapLayer.Count == mapItemsControl.Items.Count, "MapLayer and MapItemsControl.Items count should match"); } else { // Only 1 element. Create MapOverlay and insert mapLayer = new MapLayer(); MapOverlay mapOverlay; mapOverlay = MapChild.CreateMapOverlay(obj, null); mapLayer.Add(mapOverlay); } return(mapLayer); }
/// <summary> /// Inserts the item at the specified index in the target collection /// </summary> /// <param name="index">Index at which object will be inserted</param> /// <param name="obj">Object to be inserted</param> protected override void InsertItemInternal(int index, object obj) { MapOverlay mapOverlay; if (this.ObjectToMapOverlayMapping.ContainsKey(obj)) { throw new InvalidOperationException("Attempted to insert the same object twice"); } mapOverlay = MapChild.CreateMapOverlay(obj, this.ItemTemplate); this.MapLayer.Insert(index, mapOverlay); this.ObjectToMapOverlayMapping.Add(obj, mapOverlay); }