Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ColorLegend.ItemTemplate Property

Gets or sets the template that specifies the visual representation of the legend’s items.

Namespace: DevExpress.Xpf.Map

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

NuGet Package: DevExpress.Wpf.Map

#Declaration

public DataTemplate ItemTemplate { get; set; }

#Property Value

Type Description
DataTemplate

The DataTemplate object that specifies the visual representation of the legend’s items.

#Example

This example demonstrates how to customize a map legend’s items using the legend’s ColorLegend.ItemTemplate and MapLegendBase.ItemLabelTemplate properties. The legend uses these templates to create visual representations of a legend’s items and legend item labels.

Note that templates use the MapLegendItemBase and its descendant classes’ objects as the DataContext property value.

<dxm:ColorListLegend Layer="{Binding ElementName=vectorLayer}"
                     Header="GDP">
    <dxm:ColorListLegend.ItemTemplate>
        <DataTemplate>
            <StackPanel Margin="4,2,4,2" 
                        Orientation="Horizontal" >
                <Ellipse Width="16" 
                         Height="16" 
                         Fill="{Binding Fill}"/>
                <ContentControl Margin="8, 0, 0, 0" 
                                Content="{Binding}" 
                                ContentTemplate="{Binding Path=LabelTemplate}"/>
            </StackPanel>
        </DataTemplate>
    </dxm:ColorListLegend.ItemTemplate>
    <dxm:ColorListLegend.ItemLabelTemplate>
        <DataTemplate>
            <TextBlock Height="16" 
                       VerticalAlignment="Center"
                       Text="{Binding Value, Converter={StaticResource valueConverter}}"/>
        </DataTemplate>
    </dxm:ColorListLegend.ItemLabelTemplate>
</dxm:ColorListLegend>
See Also