Back to Devexpress

ChartControlBase.Legends Property

wpf-devexpress-dot-xpf-dot-charts-dot-chartcontrolbase-578a6b81.md

latest3.9 KB
Original Source

ChartControlBase.Legends Property

Returns the collection of chart legends.

Namespace : DevExpress.Xpf.Charts

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

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public LegendCollection Legends { get; }
vb
Public ReadOnly Property Legends As LegendCollection

Property Value

TypeDescription
LegendCollection

A collection of Legend objects.

|

Example

To add an additional legend to a chart, add a newly created Legend object to the ChartControlBase.Legends collection.

Dock it to the required pane or chart using the Legend.DockTarget property. Then, position the legend using the LegendBase.HorizontalPosition and LegendBase.VerticalPosition properties. Assign the legend to a chart element whose legend item should be displayed in the legend, binding the Legend property of a series, an indicator, a constant line or a strip to the legend object.

Note

Note that a legend will not be visualized until it is bound to an element’s Legend property.

xaml
<dxc:ChartControl.Legends>
    <dxc:Legend x:Name="indicatorLegend"
                DockTarget="{Binding ElementName=indicatorPane}"
                HorizontalPosition="Left"
                VerticalPosition="Top"/>
</dxc:ChartControl.Legends>
            <dxc:MovingAverageConvergenceDivergence ShowInLegend="True" 
                                                    Name="MACD"
                                                    LegendText="MACD"
                                                    dxc:XYDiagram2D.IndicatorAxisY="{Binding ElementName=indicatorAxisY}"
                                                    dxc:XYDiagram2D.IndicatorPane="{Binding ElementName=indicatorPane}"
                                                    Legend="{Binding ElementName=indicatorLegend}"/>

The following code snippets (auto-collected from DevExpress Examples) contain references to the Legends property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-bind-a-range-control-to-a-chart-control/CS/GoldPrices/MainWindow.xaml#L28

xml
</dxc:ChartControl.Palette>
<dxc:ChartControl.Legends>
    <dxc:Legend Visible="False"/>

wpf-dashboard-how-to-obtain-clicked-item-data/CS/Dashboard_ClientDataCards_Wpf/DetailedChart.xaml#L13

xml
<dxc:ChartControl x:Name="detailedChartControl">
    <dxc:ChartControl.Legends>
        <dxc:Legend/>

See Also

ChartControlBase Class

ChartControlBase Members

DevExpress.Xpf.Charts Namespace