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

dictionary DataBinding not working

1 Answer 60 Views
Sparkline
This is a migrated thread and some comments may be shown as answers.
Rama
Top achievements
Rank 1
Rama asked on 22 Feb 2011, 04:28 PM
Hi,

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" />
        </DataTemplate>


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!

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 23 Feb 2011, 04:46 PM
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,
Giuseppe
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!
Tags
Sparkline
Asked by
Rama
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or