Articles in this section
Category / Section

How to scroll the legend items in Windows Phone Chart?

2 mins read

Description:

This article describes about customizing the SfChart legend items and modify their default template.

Solution:

Scrollbar for the legends can be implemented by assigning the legend ItemsPresenter to the ScrollViewer of the legend ControlTemplate.

The customized ControlTemplate for the legend is defined in the static resource and it is assigned to the Template property of the chart legend.

XAML

<!-- Resource for the ControlTemplate of the legend is defined-->    
    <Window.Resources>
        <ControlTemplate x:Key="scroll">
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" Margin="1" >
                <ItemsPresenter />
            </ScrollViewer>
        </ControlTemplate>
    </Window.Resources>
    <!--Customized ControlTemplate from static resource is assigned to legend Template-->
                     <syncfusion:SfChart.Legend>
<syncfusion:ChartLegend DockPosition="Right" 
Template="{StaticResource scroll}">            
               </syncfusion:ChartLegend>
            </syncfusion:SfChart.Legend>

 

C#

//Customized ControlTemplate from static resource is assigned to legend Template
(this.sampleChart.Legend as ChartLegend).Template = Resources["scroll"] as ControlTemplate;

 

Screenshot:

The following screenshot illustrates the legend items with a scrollbar.

Pie Chart with legend scrollbar

Figure 1: Pie Chart with legend scrollbar

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