Back to Devexpress

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

wpf-16806-controls-and-libraries-map-control-examples-vector-data-customize-data-appearance-how-to-create-a-map-item-attribute-and-show-its-value-in-the-map-tooltip.md

latest3.9 KB
Original Source

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

  • Jun 07, 2019

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.

xaml
<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

How to: Show Titles for Map Shapes

How to: Show Tooltips for Map Shapes

How to: Customize the Appearance of a Vector Element

How to: Show a Title for a Vector Element

How to: Customize the Appearance of a Vector Element's Title

How to: Customize the Appearance of a Map Pushpin

How to: Customize Animation of a Map Pushpin

How to: Provide Cylindrical Equal-Area Projections