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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding SfChart Series Property

Thread ID:

Created:

Updated:

Platform:

Replies:

128268 Jan 11,2017 02:51 PM UTC Jan 26,2017 12:19 PM UTC Xamarin.Forms 3
loading
Tags: SfChart
Boris
Asked On January 11, 2017 02:51 PM UTC

Hello,

I'm using Xamarin Forms and building MVVM based application. I want my ViewModel to take care of number and type of series in chart, so I am trying to bind Series Property:

Chart.SetBinding(SfChart.SeriesProperty, "DataCollection"BindingMode.OneWay);
where DataCollection is defined in ViewModel:
private ChartSeriesCollection _dataCollection = new ChartSeriesCollection();
public ChartSeriesCollection DataCollection
        {
            get { return _dataCollection; }
            set
            {
                _dataCollection = value;
                OnPropertyChanged();
            }
        }
But using binding this way gives me error:

System.NullReferenceException: Object reference not set to an instance of an object.

Other bindings work all right.
Why can't I bind SeriesProperty to ChartSeriesCollection?

Yuvaraj Palanisamy [Syncfusion]
Replied On January 12, 2017 01:00 PM UTC

Hi Boris,

Thanks for contacting Syncfusion support.

We are unable to reproduce the issue at our end. Also, we had prepared a sample and attached for your reference. Please check whether you are able to reproduce the reported issue in this sample. If not, please update us the modified sample to reproduce the issue for providing further assistance.

Sample: http://www.syncfusion.com/downloads/support/forum/128268/ze/ChartSample990987186  

Please let us know if you have any concerns.

Regards,
Yuvaraj 


Boris
Replied On January 25, 2017 10:47 AM UTC

Thank you for your answer. Your example indeed works well. I found out problem was with Xamarin's binding context. I am using Prism framework and it automatically sets BindingContext of View. Problematic page had SfChart inside 3 containers (SfNavigationDrawer, ScrollView, StackLayout) so on the way BindingContext had been lost. I fixed the problem with
Chart.BindingContext = BindingContext;

And now everything works. Views that werent so deep inside containers were binding with no problems and had right binding context.

Magesh Kumar Krishnan [Syncfusion]
Replied On January 26, 2017 12:19 PM UTC

Hi Boris,

We are glad that your issue has been fixed.
Please let us know if you need any other assistance.

Regards,
Magesh




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;