How to: Create a Map Item Attribute and Show its Value in the Map Tooltip

  • 2 minutes to read

This example demonstrates how to show an area value for the triangle item in the map tooltip using the map item's attribute.

To accomplish this task, do the following:

To enable the map tooltip, set the MapControl.ToolTipEnabled property to true.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
        x:Class="UseMapItemAttribute.MainWindow"
        xmlns:core="clr-namespace:System;assembly=mscorlib"
        Title="MainWindow" Height="350" Width="525">

    <Grid>
        <dxm:MapControl ToolTipEnabled="True" >
            <!--region #AttributeInTooltip-->
            <dxm:VectorLayer Name="itemsLayer">
                <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>
            <!--endregion #AttributeInTooltip-->
        </dxm:MapControl>
    </Grid>
</Window>
See Also