We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WPF |
Control: SfChart
Tags: legend, scrollbar

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

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile