Articles in this section
Category / Section

How to add multiple legend items in scroll viewer of WPF Chart (SfChart)?

1 min read

Description:

The legend items are used to display the series label values. When a greater number of series are added to the chart, some of the legend items are hidden from the view. WPF Chart (SfChart) allows you to place the chart legend inside the scrollbar to view all the legend items. This article describes how to add multiple legend items inside the scrollbar.

Solution:

If you want to add multiple legend items inside any container such as scroll viewer, you need to define the control template for the legends in WPF Chart (SfChart).

XAML

<!—Adding ScrollViewer for Legend items-->
<chart:SfChart x:Name="sfchart" Margin="10" >
    <chart:SfChart.Legend>
        <chart:ChartLegend  DockPosition="Top">
            <chart:ChartLegend.Template>
                <ControlTemplate>
                    <ScrollViewer Margin="30" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                        <ItemsPresenter>
                        </ItemsPresenter>
                    </ScrollViewer>
                </ControlTemplate>
            </chart:ChartLegend.Template>
        </chart:ChartLegend>
    </chart:SfChart.Legend>
</chart:SfChart>

 

WPF Chart displays Multiple Items in ScrollViewer

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied