TargetInvocationException occurred while binding to Dictionary

2 posts, 0 answers
  1. Johannes
    Johannes avatar
    1 posts
    Member since:
    Nov 2013

    Posted 08 Nov 2013 Link to this post

    Hi Telerik,

    When I create a PieChart and set the Itemssource-Property to a Dictionary<string,decimal> a TargetInvocationException occurred.

    My XAML:

    <telerik:RadPieChart>
                            <telerik:RadPieChart.Series>
     
                                <telerik:PieSeries ShowLabels="True" ItemsSource="{Binding PieValues}"  >
                                    <telerik:PieSeries.ValueBinding>
                                        <telerik:PropertyNameDataPointBinding PropertyName="Value" />
                                    </telerik:PieSeries.ValueBinding>
                                    <telerik:PieSeries.LabelDefinitions>
                                        <telerik:ChartSeriesLabelDefinition Margin="-10">
                                            <telerik:ChartSeriesLabelDefinition.Binding>
                                                <telerik:PropertyNameDataPointBinding PropertyName="Key" />
                                            </telerik:ChartSeriesLabelDefinition.Binding>
                                        </telerik:ChartSeriesLabelDefinition>
                                    </telerik:PieSeries.LabelDefinitions>
                                
                                <telerik:PieSeries.AngleRange>
                                    <telerik:AngleRange StartAngle="270" SweepAngle="360" />
                                </telerik:PieSeries.AngleRange>
                            </telerik:PieSeries>
                            </telerik:RadPieChart.Series>
                        </telerik:RadPieChart>

    The PieValue ist a

    Dictionary<string, decimal>


    The Error Occurred on "OnPropertyChanged(() => PieValues);"


    Dear Johannes

  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 13 Nov 2013 Link to this post

    Hello,

    Thank you for the attached code snippets, I was able to create a new project and reproduce the issue at hand.

    You are using a Dictionary as ItemsSource. However, the Dictionary is IEnumerable<KeyValuePair>. The KeyValuePair is not a class, but a struct, and it is a limitation of the chart that properties of struct objects cannot be evaluated. What you can do, is using another collection type instead.

    Regards,
    Peshito
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top