We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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.

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

3 Replies

KO Klemen Ošlaj February 27, 2014 09:59 AM UTC

Sorry wrong attachment
Attachment: DateTimeRangeNavigatorDemo_cef1fe73.zip


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



KO Klemen Ošlaj February 28, 2014 11:49 AM UTC

Works like a charm. Thanks a lot.

Loader.
Live Chat Icon For mobile
Up arrow icon