DetachLayerEventHandlers() private method

private DetachLayerEventHandlers ( GraphicsLayer layer ) : void
layer GraphicsLayer
return void
        private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Map          oldMap = e.OldValue as Map;
            Map          newMap = e.NewValue as Map;
            EditorWidget widget = (EditorWidget)d;

            if (widget != null)
            {
                widget.editor.Map = newMap;
                if (oldMap != null && oldMap.Layers != null)
                {
                    List <GraphicsLayer> oldGraphicsLayers = new List <GraphicsLayer>();
                    foreach (Layer layer in oldMap.Layers)
                    {
                        if (layer is GraphicsLayer)
                        {
                            oldGraphicsLayers.Add(layer as GraphicsLayer);
                        }
                    }
                    widget.DetachLayerEventHandlers(oldGraphicsLayers);
                    oldMap.Layers.CollectionChanged -= widget.Layers_CollectionChanged;
                }
                if (newMap != null && newMap.Layers != null)
                {
                    newMap.Layers.CollectionChanged += widget.Layers_CollectionChanged;
                    widget.AttachLayerEventHandlers(widget.editor.GraphicsLayers);
                }
            }
        }
        private static void OnLayerIdsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            EditorWidget widget = (d as EditorWidget);

            if (widget != null)
            {
                widget.DetachLayerEventHandlers(widget.editor.GraphicsLayers);
                widget.editor.LayerIDs = widget.LayerIDs;
                widget.AttachLayerEventHandlers(widget.editor.GraphicsLayers);
            }
        }