Tooltips
- 2 minutes to read
The Map Control displays tooltips for vector items when a user clicks an item. 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:
Note
To learn how to obtain data from a shapefile, refer to the ShapefileDataAdapter help topic.
This topic consists of the following sections.
Enable Tooltips
To enable tooltips for a map, set the MapControl.ToolTipEnabled property to true.
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.
The image above shows a tooltip with the name of the country and its population. To do this, enclose the corresponding attributes from vector data files in brackets 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.
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.
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.
Note
To learn how to configure a custom map tooltip shape, refer to the How to: Implement a Custom Map Tooltip Shape example.