Chart - LinseSeries Dynamic

Thread is closed for posting
2 posts, 0 answers
  1. Marco
    Marco avatar
    4 posts
    Member since:
    Apr 2014

    Posted 30 Nov 2014 Link to this post


    I want to fill a chart dynamicaly.

    My XAML : (mainpage.xaml)


        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

                    <Chart:RadCartesianChart HorizontalAlignment="Left" 

                <Chart:LineSeries ItemsSource="{Binding}"
                        <Chart:PropertyNameDataPointBinding PropertyName="Category"/>
                        <Chart:PropertyNameDataPointBinding PropertyName="Value"/>

                <Chart:LineSeries ItemsSource="{Binding}"
                        <Chart:PropertyNameDataPointBinding PropertyName="Category"/>
                        <Chart:PropertyNameDataPointBinding PropertyName="Value"/>



    My c#  (mainpage.xaml.cs)
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;

    // The Blank Page item template is documented at

    namespace App1
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
            public MainPage()

                this.NavigationCacheMode = NavigationCacheMode.Required;
                List<GData> data1 = new List<GData>();
                data1.Add(new GData() { Category = "Apples", Value = 5 });
                data1.Add(new GData() { Category = "Oranges", Value = 9 });
                data1.Add(new GData() { Category = "Pineaples", Value = 8 });

                this.lineSeries.DataContext = data1;
                List<GData> data2 = new List<GData>();
                data2.Add(new GData() { Category = "Apples", Value = 3 });
                data2.Add(new GData() { Category = "Oranges", Value = 6 });
                data2.Add(new GData() { Category = "Pineaples", Value = 7 });

                this.lineSeries.DataContext = data2;


            protected override void OnNavigatedTo(NavigationEventArgs e)



        public class GData
            public string Category { get; set; }
            public double Value { get; set; }

    My error :

    Error 1 'App1.MainPage' does not contain a definition for 'lineSeries' and no extension method 'lineSeries' accepting a first argument of type 'App1.MainPage' could be found (are you missing a using directive or an assembly reference?)

    My question :
    What to do to solve this ?

    Thx !

  2. Ves
    Ves avatar
    2916 posts

    Posted 02 Dec 2014 Link to this post

    Hi Marco,

    The chart is not available in the code through its name lineSeries, because it is defined within a DataTemplate, which limits its namescope. Actually, that would be true for any control, not just for the chart. You can find more details here. To solve the issue, you can set DataContext property of the HubSection itself and it will be propagated to the items in it. You can find similar topics discussed in this article.

    Best regards,

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top