Binding Datapoint dynamically using property ?

2 posts, 0 answers
  1. Saravanan
    Saravanan avatar
    36 posts
    Member since:
    Jun 2011

    Posted 27 Jul 2011 Link to this post

    Hi,i have a rad chart pie series,i want to show two series, i have to bind the YPoint value dyanamically because i am using MVVM pattern,so i wrote this code,
     <telerik:ChartArea LegendName="ChartLegendManufacturers">
                                <telerik:PieSeriesDefinition ItemLabelFormat="#Y"></telerik:PieSeriesDefinition>
                            <telerik:DataPoint YValue="{Binding Items.OilPercetnage }" />
                            <telerik:DataPoint YValue="{Binding Items.WaterPercentage }" />
    and here is the code behind,
     public PieChart()
                this.LayoutRoot.DataContext = this;
            public ObservableCollection<TradeData> BindCharData()
                Items = TradeData.GetWeeklyData();
                return Items;
     public class OilData
            public double OilPercetnage {get;set;}
            public double WaterPercentage {get;set;}
            public static ObservableCollection<OilData> GetWeeklyData()
                ObservableCollection<OilData> tradeData = new ObservableCollection<OilData>();
                tradeData.Add(new OilData { OilPercetnage = 98, WaterPercentage = 55 });
                return tradeData;
    its shows error like "Object Null Value Reference ..please let me know,
    Thank you,
  2. Sia
    Sia avatar
    766 posts

    Posted 29 Jul 2011 Link to this post

    Hello Saravanan,

    I have modified your code in order to make it work correctly. Please review the attachment.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top