Skip to main content

MapCustomElementSettings.ContentTemplateSelector Property

Gets or sets the content template selector.

Namespace: DevExpress.Xpf.Map

Assembly: DevExpress.Xpf.Map.v24.1.dll

NuGet Package: DevExpress.Wpf.Map

Declaration

public DataTemplateSelector ContentTemplateSelector { get; set; }

Property Value

Type Description
DataTemplateSelector

A DataTemplateSelector object.

Property Paths

You can access this nested property as listed below:

Object Type Path to ContentTemplateSelector
MapCustomElementSettings
.Default .ContentTemplateSelector

Example

This example demonstrates how to use several templates for generated custom map elements.

To do this, specify the MapCustomElementSettings.ContentTemplateSelector property of the MapCustomElementSettings object assigned to the ListSourceDataAdapter.ItemSettings property.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MapCustomElementSettings"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
        x:Class="MapCustomElementSettings.MainWindow"
        Title="MainWindow" Height="350" Width="525"
        Loaded="Window_Loaded">
    <Window.Resources>
        <XmlDataProvider x:Key="dataSet" Source="disasters.xml" XPath="/Disasters"/>
        <DataTemplate x:Key="AirRaidsMapMarker">
            <Ellipse Fill="LightBlue" Width="20" Height="20">
                <Ellipse.RenderTransform>
                    <TranslateTransform X="-10" Y="-10"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </DataTemplate>
        <DataTemplate x:Key="BushfiresMapMarker">
            <Ellipse Fill="Firebrick" Width="20" Height="20">
                <Ellipse.RenderTransform>
                    <TranslateTransform X="-10" Y="-10"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </DataTemplate>
        <DataTemplate x:Key="CycloneMapMarker">
            <Ellipse Fill="LightSlateGray" Width="20" Height="20">
                <Ellipse.RenderTransform>
                    <TranslateTransform X="-10" Y="-10"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </DataTemplate>
        <DataTemplate x:Key="EpidemicMapMarker">
            <Ellipse Fill="DarkOliveGreen" Width="20" Height="20">
                <Ellipse.RenderTransform>
                    <TranslateTransform X="-10" Y="-10"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </DataTemplate>
        <DataTemplate x:Key="SinkingMapMarker">
            <Ellipse Fill="Blue" Width="20" Height="20">
                <Ellipse.RenderTransform>
                    <TranslateTransform X="-10" Y="-10"/>
                </Ellipse.RenderTransform>
            </Ellipse>
        </DataTemplate>
        <DataTemplate x:Key="tooltipTemplate">
            <StackPanel Orientation="Vertical" Margin="4">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Padding="4" Text="Disaster Type:" Foreground="#FFE2E2E2" FontSize="18"/>
                    <TextBlock Padding="4" Text="{Binding Item.Type}" Foreground="#FFE2E2E2" FontSize="18"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Padding="4,2,2,2" Text="Location:" Foreground="#FFE2E2E2" FontSize="14"/>
                    <TextBlock Padding="2,2,2,4" Text="{Binding Item.LocationName}" Foreground="#FFE2E2E2" FontSize="14"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Padding="4,2,2,4" Text="Deaths:" Foreground="#FFE2E2E2" FontSize="14"/>
                    <TextBlock Padding="4,2,2,4" Text="{Binding Item.Deaths}" Foreground="#FFE2E2E2" FontSize="14"/>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <dxm:MapControl CenterPoint="-25, 135" ZoomLevel="3" ToolTipEnabled="True">
            <dxm:ImageTilesLayer>
                <dxm:BingMapDataProvider BingKey="Your Bing Key"/>
            </dxm:ImageTilesLayer>
            <dxm:VectorLayer ToolTipContentTemplate="{StaticResource tooltipTemplate}">
                <dxm:ListSourceDataAdapter DataSource="{Binding Disasters}">
                    <dxm:ListSourceDataAdapter.AttributeMappings>
                        <dxm:MapItemAttributeMapping Name="LocationName" Member="LocationName"/>
                        <dxm:MapItemAttributeMapping Name="Type" Member="Type"/>
                        <dxm:MapItemAttributeMapping Name="Deaths" Member="Deaths"/>
                    </dxm:ListSourceDataAdapter.AttributeMappings>
                    <dxm:ListSourceDataAdapter.Mappings>
                        <dxm:MapItemMappingInfo Latitude="LocationLatitude" 
                                                Longitude="LocationLongitude"/>
                    </dxm:ListSourceDataAdapter.Mappings>
                    <dxm:ListSourceDataAdapter.ItemSettings>
                        <dxm:MapCustomElementSettings>
                            <dxm:MapCustomElementSettings.ContentTemplateSelector>
                                <local:MarkerTemplateSelector 
                                    AirRaidsDataTemplate="{StaticResource AirRaidsMapMarker}"
                                    BushfiresDataTemplate="{StaticResource BushfiresMapMarker}"
                                    CycloneDataTemplate="{StaticResource CycloneMapMarker}"
                                    EpidemicDataTemplate="{StaticResource EpidemicMapMarker}"
                                    SinkingDataTemplate="{StaticResource SinkingMapMarker}"/>
                            </dxm:MapCustomElementSettings.ContentTemplateSelector>
                        </dxm:MapCustomElementSettings>
                    </dxm:ListSourceDataAdapter.ItemSettings>
                </dxm:ListSourceDataAdapter>
            </dxm:VectorLayer>
        </dxm:MapControl>
    </Grid>
</Window>
See Also