ClearMapOverlayBindings() статический приватный Метод

Clear the bindings created when the overlay was created by MapChild
static private ClearMapOverlayBindings ( MapOverlay mapOverlay ) : void
mapOverlay MapOverlay MapOverlay that was created by MapChild
Результат void
        /// <summary>
        /// Implements the RemoveItemInternal from the parent class.
        /// Will take the object and remove the target item from the Map.Layers collection
        /// </summary>
        /// <param name="obj">Object to be removed</param>
        protected override void RemoveItemInternal(DependencyObject obj)
        {
            bool mappingContainsObject;

            mappingContainsObject = this.ObjectToMapLayerMapping.ContainsKey(obj);

            Debug.Assert(mappingContainsObject, "It is expected that there is a mapping for the object");

            if (mappingContainsObject)
            {
                MapLayer mapLayer;

                mapLayer = this.ObjectToMapLayerMapping[obj];
                this.ObjectToMapLayerMapping.Remove(obj);
                this.Map.Layers.Remove(mapLayer);

                if (!(obj is MapItemsControl))
                {
                    Debug.Assert(mapLayer.Count == 1, "Expected that the map overlay once created is still there");
                }

                // Clear the bindings in the map overlays.
                foreach (MapOverlay mapOverlay in mapLayer)
                {
                    MapChild.ClearMapOverlayBindings(mapOverlay);
                }
            }
        }
        /// <summary>
        /// Resets the target collection and internal state
        /// </summary>
        protected override void ResetInternal()
        {
            foreach (MapOverlay mapOverlay in this.MapLayer)
            {
                MapChild.ClearMapOverlayBindings(mapOverlay);
            }

            this.MapLayer.Clear();
            this.ObjectToMapOverlayMapping.Clear();
        }
        /// <summary>
        /// Implements the behavior the target collection will have when the source is reset
        /// </summary>
        protected override void ResetInternal()
        {
            // The source collection has changed drastically enough.
            // Clear all the MapOverlay bindings.
            foreach (MapLayer mapLayer in this.Map.Layers)
            {
                foreach (MapOverlay mapOverlay in mapLayer)
                {
                    MapChild.ClearMapOverlayBindings(mapOverlay);
                }
            }

            this.Map.Layers.Clear();
            this.ObjectToMapLayerMapping.Clear();
        }
        /// <summary>
        /// Remove the specified item from the target collection
        /// </summary>
        /// <param name="obj">Object to be removed</param>
        protected override void RemoveItemInternal(object obj)
        {
            bool mappingContainsObject;

            mappingContainsObject = this.ObjectToMapOverlayMapping.ContainsKey(obj);

            Debug.Assert(mappingContainsObject, "expected to have a mapping for the object");

            if (mappingContainsObject)
            {
                MapOverlay mapOverlay;

                mapOverlay = this.ObjectToMapOverlayMapping[obj];
                this.ObjectToMapOverlayMapping.Remove(obj);
                this.MapLayer.Remove(mapOverlay);

                MapChild.ClearMapOverlayBindings(mapOverlay);
            }
        }
Пример #5
0
        /// <summary>
        /// Will handle the item template change
        /// </summary>
        /// <param name="d">DependencyObject that triggers the event.</param>
        /// <param name="e">Event args</param>
        private static void OnItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MapItemsControl mapsItemControl;
            DataTemplate    dataTemplate;

            mapsItemControl = (MapItemsControl)d;
            dataTemplate    = (DataTemplate)e.NewValue;

            mapsItemControl.ItemsChangeManager.ItemTemplate = dataTemplate;

            foreach (MapOverlay mapOverlay in mapsItemControl.MapLayer)
            {
                // New template, so there will be a new ui element created
                MapChild.ClearMapOverlayBindings(mapOverlay);

                MapOverlayItem mapOverlayPresenterHelper = (MapOverlayItem)mapOverlay.Content;
                mapOverlayPresenterHelper.ContentTemplate = dataTemplate;
            }
        }