Does ItemMapping support dot notation?

2 posts, 1 answers
  1. Maxim
    Maxim avatar
    16 posts
    Member since:
    Jun 2008

    Posted 28 Jan 2011 Link to this post

    If I have two classes as follows:
    public class Defect
    {
        public DateTime DefectDate { get; set; }
        public double QuanityDefective { get; set; }
        public Customer CustomerName { get; set; }
    }

    public class Customer
    {
        public string Name { get; set; }
        public string City { get; set; }
    }

    If I bind my chart to an ObservableCollection of Defect, can I map the Xaxis field as Customer.Name?
  2. Answer
    Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 Feb 2011 Link to this post

    Hi Jeff,

    Indeed, you can set the itemmapping to a nested property. This may look something like this:

    public class MyClass
       {
           public test _yvalue;
           public test MyClassProperty
           {
               get
               {
                   return this._yvalue;
               }
               set
               {
                   this._yvalue = value;
               }
           }
       }
       public class test
       {
           int _innerValue;
           public int InnerValue
           {
               get
               {
                   return _innerValue;
               }
               set
               {
                   _innerValue = value;
               }
           }
       }

    public MainPage()
           {
               InitializeComponent();
                 
               List<MyClass> chartDataSource = new List<MyClass> ();
               test innerEntry;
               MyClass entry = new MyClass();
               innerEntry = new test();
               innerEntry.InnerValue = 12;
               entry.MyClassProperty = innerEntry;
               chartDataSource.Add(entry);
               entry = new MyClass();
               innerEntry = new test();
               innerEntry.InnerValue = 4;
               entry.MyClassProperty = innerEntry;
               chartDataSource.Add(entry);
                            
               SeriesMapping mapping1 = new SeriesMapping();
               mapping1.SeriesDefinition = new PieSeriesDefinition();
               mapping1.SeriesDefinition.InteractivitySettings.SelectionMode = ChartSelectionMode.Single;
               mapping1.SeriesDefinition.InteractivitySettings.SelectionScope = InteractivityScope.Item;
               ItemMapping itemmaping1 = new ItemMapping();
               itemmaping1.DataPointMember = DataPointMember.YValue;
               itemmaping1.FieldName = "MyClassProperty.InnerValue";
               mapping1.ItemMappings.Add(itemmaping1);
               RadChart1.SeriesMappings.Add(mapping1);
               
               RadChart1.ItemsSource = chartDataSource;
                
           }

    I hope this information helps.

    All the best,
    Yavor
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top