dictionary DataBinding not working

2 posts, 0 answers
  1. Rama
    Rama avatar
    15 posts
    Member since:
    Feb 2011

    Posted 22 Feb 2011 Link to this post


    I've demo to senior managers tomorrow(telerik trial version!) so I hope to get an answer from telerik as soon as possible.

    I'm having issues in databinding:

       <DataTemplate x:Name="sparklineTemplate">
                <telerik:RadAreaSparkline ShowAxis="False" Width="120" Height="40"  Visibility="Visible"   ItemsSource="{Binding DataPoints}" XValuePath="Key" YValuePath="Value" />

    But the trouble is, I don't have direct binding path but something like the following:

    var bindingPath = string.Format("DataPoints[{0}]", date);
                    var bin = new Binding(bindingPath)

    How do I represent same in DataTemplate?

    Please note that my DataPoints is a dictionary : Dictionary<string,double>

    so how do you bind to dictionary?

    ItemsSource="{Binding DataPoints}" XValuePath="Key" YValuePath="Value"

    Key & Value is not working!
  2. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 23 Feb 2011 Link to this post

    Hi Rama,

    Silverlight does not support such type of dynamic resolution of XValuePath / YValuePath properties -- their values must be static. The framework does not support the DataTemplateSelector concept either but you can try to implement it on your own -- check the following article to get you started.

    As for your dictionary question -- the XValuePath must resolve to numeric (double) or DateTime property, string values (i.e. categorical mode) are not supported. So you will be able to bind to Dictionary<double, double> or Dictionary<DateTime, double> but not to Dictionary<string, double>.

    All the best,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top