MapCustomElementSettings.ContentTemplate Property
Gets or sets the content template displaying custom elements generated using these settings.
Namespace: DevExpress.Xpf.Map
Assembly: DevExpress.Xpf.Map.v24.2.dll
NuGet Package: DevExpress.Wpf.Map
Declaration
Property Value
Type | Description |
---|---|
DataTemplate | A DataTemplate object. |
Property Paths
You can access this nested property as listed below:
Object Type | Path to ContentTemplate |
---|---|
MapCustomElementSettings |
|
Example
This example demonstrates how to customize the appearance and behavior of automatically generated custom map elements. The MapCustomElementSettings class allows specifying parameters of the adapter generated map custom elements.
To do this, assign a MapCustomElementSettings object to the ListSourceDataAdapter.ItemSettings property, and customize one or several of the following properties.
- MapCustomElementSettings.Template - allows specifying the appearance and behavior of custom generated elements.
MapCustomElementSettings.ContentTemplate
- allows specifying the appearance of data displayed in custom elements.- MapCustomElementSettings.ContentTemplateSelector - allows specifying the selector that chooses a template based on data properties.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" x:Class="MapCustomElementSettings.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<XmlDataProvider x:Key="data" Source="Data/Ships.xml" XPath="/Ships"/>
<ControlTemplate x:Key="template">
<Border Name="border" BorderThickness="2" Padding="4"
BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"
Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
<ContentControl Content="{Binding MapItem.Content}"
ContentTemplate="{Binding MapItem.ContentTemplate}"/>
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="BorderBrush.Color"
Storyboard.TargetName="border"
To="{x:Static SystemColors.HotTrackColor}"
Duration="0:0:0"/>
<ColorAnimation Storyboard.TargetProperty="Background.Color"
Storyboard.TargetName="border"
To="{x:Static SystemColors.HighlightColor}"
Duration="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Mouse.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="BorderBrush.Color"
Storyboard.TargetName="border"
To="{x:Static SystemColors.ControlDarkDarkColor}"
Duration="0:0:0"/>
<ColorAnimation Storyboard.TargetProperty="Background.Color"
Storyboard.TargetName="border"
To="{x:Static SystemColors.ControlLightColor}"
Duration="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<DataTemplate x:Key="contentTemplate">
<StackPanel Orientation="Horizontal">
<Image Width="32" Height="32" Source="Images/Ship.png"/>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Year}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<dxm:MapControl CenterPoint="-37, 147" ZoomLevel="5">
<dxm:ImageTilesLayer>
<dxm:BingMapDataProvider BingKey="Your Bing Key"/>
</dxm:ImageTilesLayer>
<dxm:VectorLayer>
<dxm:ListSourceDataAdapter DataSource="{Binding Source={StaticResource data}, XPath=Ship}">
<dxm:ListSourceDataAdapter.Mappings>
<dxm:MapItemMappingInfo Latitude="Latitude" Longitude="Longitude"/>
</dxm:ListSourceDataAdapter.Mappings>
<dxm:ListSourceDataAdapter.ItemSettings>
<dxm:MapCustomElementSettings Template="{StaticResource template}"
ContentTemplate="{StaticResource contentTemplate}"/>
</dxm:ListSourceDataAdapter.ItemSettings>
</dxm:ListSourceDataAdapter>
</dxm:VectorLayer>
</dxm:MapControl>
</Grid>
</Window>
See Also