Events in WPF Maps (SfMap)

18 Nov 20183 minutes to read

ZoomedIn - Occurs whenever zooming in the map.
ZoomedOut - Occurs when zooming out the map.
Panning - Occurs while panning the map.
Panned - Occurs after panning the map.
MapToolTipOpening - Occurs when any tooltip on the SfMap control is opened.

Tooltip opening event

The MapToolTipOpening event occurs whenever you select a shape, bubble, or marker. You will get the Data and TooltipType properties as arguments from the TooltipOpeningEventArgs handler, and you can cancel the event for a particular shape using the Cancel property.

<maps:SfMap MapToolTipOpening="Map_MapToolTipOpening" >
            <maps:SfMap.Layers>               
                <maps:ShapeFileLayer Uri="MapsZoom.ShapeFiles.usa_state.shp" ItemsSource="{Binding Data}" 
                                     ShapeIDPath="State" ShapeIDTableField="STATE_NAME" 
                                     EnableSelection="False" LabelPath="State">
                    <maps:ShapeFileLayer.ShapeSettings>
                        <maps:ShapeSetting   ShapeStrokeThickness="1" ></maps:ShapeSetting>
                    </maps:ShapeFileLayer.ShapeSettings>
                    <maps:ShapeFileLayer.ToolTipSettings>
                        <maps:ToolTipSetting ValuePath="Candidate" x:Name="shapeTooltipSettings" >
                        </maps:ToolTipSetting>
                    </maps:ShapeFileLayer.ToolTipSettings>
                </maps:ShapeFileLayer>
	       </maps:SfMap.Layers>
        </maps:SfMap>
private void SfMaps_TooltipOpening(object sender, TooltipOpeningEventArgs e)
        {
        if ((e.Data is MapsZoom.ElectionData) && (e.Data as MapsZoom.ElectionData).State == "North Dakota")
        {
            e.Cancel = true;
        }
        }

NOTE

You can refer to our WPF Map feature tour page for its groundbreaking feature representations. You can also explore our WPF Map example to know how to render and configure the map.