This is a migrated thread and some comments may be shown as answers.

dynamic object / expandoobject bind to itemsource?

1 Answer 114 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tony
Top achievements
Rank 1
Tony asked on 29 May 2012, 09:48 AM
I tried to bind  dynamic list like below but failed.

 

ObservableCollection<dynamic>       cases     
 mapping.ItemsSource = cases     ;


mapping.ItemMappings.Add(new ItemMapping(this.YValue, DataPointMember.YValue));


It seems something wrong with the seriesmapping?
Is it possible to bind a dynamic object list to a line chart or bar chart?

P.S
I use linq to query the dynamic objects
IEnumerable<dynamic> callStats = (from c in ipCases
                            group c by c.Year into d
                            select new
                            {
                                Year = Convert.ToInt32(d.Key.ToString()),
                                CaseCounts = d.Sum(x => x.CaseCount)
                            } as dynamic);


Thanks!

1 Answer, 1 is accepted

Sort by
0
Rosko
Telerik team
answered on 01 Jun 2012, 09:50 AM
Hi Tony,

We investigated closely the scenario. The problem is caused by the security model of the Silverlight platform. RadChart is not expected to work under these cirumstances. The UI control does not have access to the object, because of the Silverlight security restrictions. You can read about the topic over here. There is a possible workaround for this. You can create another class to which you will bind to the RadChart. You just need to cast the result of the LINQ query to that object. You can see the code snippet for further help.

public class HelperType
        {
            public int Year { get; set; }
            public int CaseCounts { get; set; }
        }

IEnumerable<dynamic> callStats = (from c in ipCases
                                              group c by c.Year into d
                                              select new HelperType
                                              {
                                                  Year = Convert.ToInt32(d.Key.ToString()),
                                                  CaseCounts = d.Sum(x => x.CaseCount)
                                              });

Greetings,
Rosko
the Telerik team

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

Tags
Chart
Asked by
Tony
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Share this question
or