Back to Devexpress

How to: Add an Additional Legend

wpf-116011-controls-and-libraries-charts-suite-chart-control-examples-chart-elements-how-to-add-an-additional-legend.md

latest2.0 KB
Original Source

How to: Add an Additional Legend

  • Jun 07, 2019

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}"/>

See Also

Series.Legend

Indicator.Legend

ConstantLine.Legend

Strip.Legend