DateTime RangeNavigator C# binding
I am wondering, how can I bind SelectedData property of RangeNavigator to charts series itemsource using C#? I need this, because I create Chart series dynamically in C#, so I have to set binding there. But thus far I was unsuccessful.
Attachment: DateTimeRangeNavigator_284b07cd.zip
Here is piece of code:
((Model)holder.DataContext).Chart = new SfChart();
((Model)holder.DataContext).Chart.PrimaryAxis = new DateTimeAxis();
((Model)holder.DataContext).Chart.SecondaryAxis = new NumericalAxis();
((Model)holder.DataContext).Chart.Series = new ChartSeriesCollection();
ColumnSeries column = new ColumnSeries();
column.XBindingPath = "_Date";
column.YBindingPath = "High";
Binding b = new Binding();
b.Source = RangeNavigator.SelectedData;
b.ElementName = "RangeNavigator";
column.SetBinding(ColumnSeries.ItemsSourceProperty, b);
((Model)holder.DataContext).Chart.Series.Add(column);
Error:
Error: Converter failed to convert value of type 'Syncfusion.UI.Xaml.Charts.SfDateTimeRangeNavigator' to type 'IBindableIterable'; BindingExpression: Path='' DataItem='Syncfusion.UI.Xaml.Charts.SfDateTimeRangeNavigator'; target element is 'Syncfusion.UI.Xaml.Charts.ColumnSeries' (Name='null'); target property is 'ItemsSource' (type 'IBindableIterable').
Attachment: DateTimeRangeNavigator_284b07cd.zip
SIGN IN To post a reply.
3 Replies
KO
Klemen Ošlaj
February 27, 2014 09:59 AM UTC
SK
Satheesh Kumar T
Syncfusion Team
February 28, 2014 11:23 AM UTC
Hi Klemen,
Thanks for using Syncfusion Products.
We have analyzed your query and given sample. The issue is due to the problem with your binding. This can be fixed as in below code snippet.
Code Snippet [C#]:
ColumnSeries column = new ColumnSeries();
column.XBindingPath = "_Date";
column.YBindingPath = "High";
Binding sourceBind = new Binding();
sourceBind.Source = RangeNavigator;
sourceBind.Path = new PropertyPath("SelectedData");
column.SetBinding(ColumnSeries.ItemsSourceProperty, sourceBind);
Please let us know if you have any queries.
Thanks
Satheesh Kumar T
Thanks for using Syncfusion Products.
We have analyzed your query and given sample. The issue is due to the problem with your binding. This can be fixed as in below code snippet.
Code Snippet [C#]:
ColumnSeries column = new ColumnSeries();
column.XBindingPath = "_Date";
column.YBindingPath = "High";
Binding sourceBind = new Binding();
sourceBind.Source = RangeNavigator;
sourceBind.Path = new PropertyPath("SelectedData");
column.SetBinding(ColumnSeries.ItemsSourceProperty, sourceBind);
Please let us know if you have any queries.
Thanks
Satheesh Kumar T
KO
Klemen Ošlaj
February 28, 2014 11:49 AM UTC
Works like a charm. Thanks a lot.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
KO Klemen Ošlaj
- Feb 27, 2014 09:54 AM UTC
- Feb 28, 2014 11:49 AM UTC