This is a migrated thread and some comments may be shown as answers.
How to set the ItemsSource property of a SeriesMapping in code-behind
2 Answers 46 Views
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 27 Dec 2011, 04:02 PM
Hi,

I'm looking to dynamically set the ItemsSource property of a SeriesMapping in code-behind. Here's the XAML I'm trying to achieve:
<telerik:SeriesMapping
    x:Name="EventTypeSeries"
    ItemsSource="{Binding EventAlarmLog}">

The code I'd like to use is as follows:
EventTypeSeries.SetBinding(SeriesMapping.ItemsSourceProperty, "EventAlarmLog")

However, there is no function "SetBinding" for a SeriesMapping. I am able to do this in code-behind for the entire chart (which I am doing right now), however I'd like to chart a series from a separate data source and specify bind the "ItemsSource" property of the individual series in code-behind (so that the "ItemsSource" can be dynamically built). How can I do this?

Kind regards,
Dave.

2 Answers, 1 is accepted

Sort by
0
Accepted
Bartholomeo Rocca
Top achievements
Rank 1
answered on 28 Dec 2011, 09:11 AM
Hello Dave,

You should be able to achieve the desired effect via the BindingOperations.SetBinding(...) static method -- this is the way to attach a binding to an arbitrary DependencyObject that may not expose its own SetBinding method.


Greetings,
Bart.
0
David
Top achievements
Rank 2
answered on 28 Dec 2011, 01:36 PM
Hi Bart,

Great answer! Here's the code I ended up using:
BindingOperations.SetBinding(EventTypeSeries, SeriesMapping.ItemsSourceProperty, New Binding("EventAlarmLog"))

Kind regards,
Dave.
Tags
Chart
Asked by
David
Top achievements
Rank 2
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
David
Top achievements
Rank 2
Share this question
or