How to: Create a Map Item Attribute and Show its Value in the Map Tooltip
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:
- Create a map triangle using the MapPolygon item;
- Create a MapItemAttribute object using the MapItem.Attributes property;
- Specify the attribute name, type, and value in corresponding properties (MapItemAttribute.Name, MapItemAttribute.Type, and MapItemAttribute.Value);
- Specify the triangle area attribute using the MapItem.ToolTipPattern property.
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