e.handled的用法

        void gl_MouseLeftButtonDownCompleted(object sender, GraphicMouseButtonEventArgs e)
        {
            Graphic clickedGraphic = e.Graphic;
            if (clickedGraphic != null)
            {
                DZInfoWindow.Anchor = clickedGraphic.Geometry.Extent.GetCenter();
                DZInfoWindow.IsOpen = true;
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                DZInfoWindow.Content = clickedGraphic.Attributes;
                myMap.PanTo(clickedGraphic.Geometry);
            }
            e.Handled = true;
            return;
        }


        private void myMap_MouseClick(object sender, Map.MouseEventArgs e)
        {
            DZInfoWindow.IsOpen = false;
            
        }

  esri:map中有graphiclayer图层。点击graphiclayer中的graphic后,会触发graphiclayer的mousebuttondown事件,打开Infowindow。如果不设置e.handled=true。那么还会触发map中的mouseclick事件,导致infowindow打开后又关闭,设置了e.handled=true后,在graphicmousebuttondown后,事件就终结了,不会触发mapmouseclick事件。实现类似百度的打开、关闭信息窗口效果。

原文地址:https://www.cnblogs.com/xlyg-14/p/4154990.html