Tooltips

  • 2 minutes to read

The Map control supports map tooltips. Tooltips can be used to provide map items with additional information.

The following image illustrates a tooltip attached to a vector item generated from a shapefile.

MapControl_tooltip

NOTE

To learn how to obtain data from a shapefile, refer to the Load Vector Data from a Shapefile help topic.

This topic consists of the following sections.

Enable Tooltips

To enable tooltips for a map, set the MapControl.ToolTipEnabled property to true.

ToolTipEnabled

Customize the Tooltip Appearance

To configure the tooltip appearance, use the ways described below.

  • When you need to modify tooltip text patterns for all vector layer items, use the VectorLayerBase.ToolTipPattern property.

    ToolTipPattern

    The image above demonstrates the tooltip, showing the name of the country and its population. For this, enclose in brackets the corresponding attributes obtained from vector data files to define the ToolTipPattern property.

    <dxm:VectorLayer ToolTipPattern="{}{NAME}: {POP_EST}">
             <!--...-->
    </dxm:VectorLayer>
    
  • Use the MapItem.ToolTipPattern property to set a pattern of text displayed in tooltips for each individual vector element. To configure tooltip content, use map item attributes stored in the MapItem.Attributes collection.

    MapItemTooltipPattern

    To show vector item attribute data in a tooltip, use the following code.

    <dxm:VectorLayer SelectedShapeFill="#5b9bd5">
          <dxm:MapItemStorage>
                <dxm:MapPolygon ToolTipPattern="{}Triangle Area: {areaValueAttrName}" 
                      Points="0,0,0,40,40,0,0,0">
                      <dxm:MapPolygon.Attributes>
                            <dxm:MapItemAttribute Name="areaValueAttrName" 
                                  Type="{x:Type sys:Double}" 
                                  Value="80"/>
                      </dxm:MapPolygon.Attributes>
                </dxm:MapPolygon>
          </dxm:MapItemStorage>
    </dxm:VectorLayer>
    
  • The VectorLayerBase.ToolTipContentTemplate property specifies the presentation of the tooltip content for a vector element.

    TooltipContentTemplate

    NOTE

    To learn how to modify the tooltip content, refer to the How to: Show Tooltips for Map Shapes example.

  • The MapControl.ToolTipTemplate property defines how tooltips will be displayed. Assign a DataTemplate object to this property to configure a custom form of tooltips.

    ToolTipTemplate

    NOTE

    To learn how to configure a custom map tooltip shape, refer to the How to: Implement a Custom Map Tooltip Shape example.