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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GalaSoft data binding

Thread ID:

Created:

Updated:

Platform:

Replies:

145567 Jun 28,2019 07:22 AM UTC Jul 2,2019 06:30 AM UTC Xamarin.Android 3
loading
Tags: SfChart
Markus
Asked On June 28, 2019 07:22 AM UTC

Hi,

try to bind the ItemsSource of a BarSeries to a collection of my ViewModel. I have the following code:

_barSeries = new BarSeries {
    ListenPropertyChange = true,
    XBindingPath = nameof(ChartData.Name),
    YBindingPath = nameof(ChartData.Value),
    TooltipEnabled = true,
    EnableAnimation = true,
    AnimationDuration = 0.8
};
_chartView.Series.Add(_barSeries);

var test = this.SetBinding(() => ViewModel.ChartCollection, () => _barSeries.ItemsSource);
But the chartview doesn't show anything. Is it possible to do a data binding with Xamarin.Android SfChart? Any suggestions? Thank you.

Rachel A [Syncfusion]
Replied On July 2, 2019 05:19 AM UTC

Hi Markus, 
 
Thanks for contacting Syncfusion Support. 
 
We have analyzed your code snippet and tried to bind the ItemSource of a BarSeries to a collection of ViewModel. But we are unable to bind the ItemSource property as it is of type IEnumerable. So, we have achieved your requirement by creating a custom class inheriting BarSeries and creating a property of type ObservableCollection and binding that property to ViewModel collection. We have attached the sample for your reference, and it can be downloaded from the below link. 
 
 
Code snippet [C#] - BarSeriesExt 
public class BarseriesExt : BarSeries 
{ 
    private ObservableCollection<ChartData> data; 
    public ObservableCollection<ChartData> Data 
    { 
        get { return data; } 
        set 
        { 
            if (data != value) 
            { 
                data = value; 
                ItemsSource = data; 
            } 
        } 
    } 
} 
 
Code snippet [C#] – MainActivity.cs 
this.SetBinding(() => Vm.BarData, () => Series.Data); 
 
Please let us know if you have any concerns. 
 
Regards, 
Rachel. 
 


Markus
Replied On July 2, 2019 06:21 AM UTC

Thank you, for your reply. With this hint, I can add my bindings.

Rachel A [Syncfusion]
Replied On July 2, 2019 06:30 AM UTC

Hi Markus, 
 
Thanks for the update. 
 
Please revert to us if you have any queries. 
 
Thanks, 
Rachel. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon