Back to Devexpress

LegendBase.ItemTemplate Property

wpf-devexpress-dot-xpf-dot-charts-dot-legendbase-2c1a6563.md

latest2.4 KB
Original Source

LegendBase.ItemTemplate Property

Gets or sets the DataTemplate that specifies how to represent an item in the legend.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public DataTemplate ItemTemplate { get; set; }
vb
Public Property ItemTemplate As DataTemplate

Property Value

TypeDescription
DataTemplate

A DataTemplate object that contains the template for the legend items.

|

Example

The following markup configures legend items that belong to series:

xaml
<dxc:ChartControl.Legends>
    <dxc:Legend HorizontalPosition="Left" 
                VerticalPosition="Top" 
                Orientation="Vertical">
        <dxc:Legend.ItemTemplate>
            <DataTemplate>
                <dxc:LegendItemContainer>
                    <Grid Width="12" Height="12">
                        <Rectangle Stretch="Uniform" 
                                   Fill="Transparent"/>
                        <dxc:ChartContentPresenter Content="{Binding}" 
                                                   ContentTemplate="{Binding Path=MarkerTemplate}"/>
                    </Grid>
                    <TextBlock Text="{Binding Path=Text}" 
                               VerticalAlignment="Center" 
                               MaxWidth="250" 
                               Margin="4"
                               Foreground="{Binding Path=MarkerBrush}"/>
                </dxc:LegendItemContainer>
            </DataTemplate>
        </dxc:Legend.ItemTemplate>
    </dxc:Legend>
</dxc:ChartControl.Legends>

See Also

ItemsPanel

LegendBase Class

LegendBase Members

DevExpress.Xpf.Charts Namespace