Getting Started with Xamarin Sparkline (SfSparkline)

18 May 20217 minutes to read

This section explains you the steps required to populate the Sparkline with data.

Assembly deployment

After installing Essential Studio for Xamarin, you can find all the required assemblies in the installation folders, {Syncfusion Essential Studio Installed location} \Essential Studio\{Version #}\Xamarin\lib.

E.g.: C:\Program Files (x86) \Syncfusion\Essential Studio\\Xamarin\lib


Assemblies can be found in unzipped package location(Documents/Syncfusion/{Version #}/Xamarin/lib) in Mac.

Adding SfSparkline reference

You can add SfSparkline reference using one of the following methods:

Method 1: Adding SfSparkline reference from

Syncfusion Xamarin components are available in To add SfSparkline to your project, open the NuGet package manager in Visual Studio, search for Syncfusion.Xamarin.SfSparkline, and then install it.

Adding SfSparkline reference from NuGet


Install the same version of SfSparkline NuGet in all the projects.

Method 2: Adding SfSparkline reference from toolbox

Syncfusion also provides Xamarin Toolbox. Using this toolbox, you can drag the SfSparkline control to the XAML page. It will automatically install the required NuGet packages and add the namespace to the page. To install Syncfusion Xamarin Toolbox, refer to Toolbox.

Method 3: Adding SfSparkline assemblies manually from the installed location

If you prefer to manually reference the assemblies instead referencing from NuGet, add the following assemblies in respective projects.

Location: {Installed location}/{version}/Xamarin/lib

PCL Syncfusion.SfSparkline.XForms.dll
Android Syncfusion.SfSparkline.Android.dll
iOS Syncfusion.SfSparkline.iOS.dll
UWP Syncfusion.SfSparkline.UWP.dll


To know more about obtaining our components, refer to these links for Mac and Windows.


Starting with v16.2.0.x, if you reference Syncfusion assemblies from the trial setup or from the NuGet feed, you also have to include a license key in your projects. Please refer to Syncfusion license key to know about registering Syncfusion license key in your Xamarin application to use our components.

Launching an application on each platform with SfSparkline.

To use the SfSparkline control inside an application, each platform requires some additional configurations. The configurations vary from platform to platform and is discussed in the following sections:


If you are adding the references from toolbox, this step is not needed.


To launch the SfSparkline in iOS, call the SfSparklineRenderer.Init() in the FinishedLaunching overridden method of the AppDelegate class after the Xamarin.Forms Framework has been initialized and before the LoadApplication is called, as demonstrated in the following code example.

  • C#
  • public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        global::Xamarin.Forms.Forms.Init ();
        LoadApplication (new App ());

    Universal Windows Platform (UWP)

    You need to initialize the sparkline view assemblies in App.xaml.cs in UWP project as demonstrated in the following code samples. This is required to deploy the application with sparkline in Release mode in UWP platform.

  • C#
  • // In App.xaml.cs
    protected override void OnLaunched(LaunchActivatedEventArgs e)
        	    rootFrame.NavigationFailed += OnNavigationFailed;
            // Add `using System.Reflection;`
            List<Assembly> assembliesToInclude = new List<Assembly>();
            // Now, add all the assemblies your app uses                 
            // Replaces Xamarin.Forms.Forms.Init(e);        
            Xamarin.Forms.Forms.Init(e, assembliesToInclude);	


    The Android platform does not require any additional configuration to render the sparkline.

    Initialize view model

    Now, let us define a simple data model that represents a data point in SfSparkline.

  • C#
  • public class Model   
        public double Performance { get; set; }

    Next, create a view model class and initialize a list of Model objects as shown below,

  • C#
  • public class ViewModel  
          public List<Model> Data { get; set; }      
          public ViewModel()       
                Data = new List<Model>()
                    new Model { Performance = 3000 },
                    new Model { Performance = 5000 },
                    new Model { Performance = -3000 },
                    new Model { Performance = -4000 },
                    new Model { Performance = 2000 },
                    new Model { Performance = 3000 }

    Set the ViewModel instance as the BindingContext of your Page; this is done to bind properties of ViewModel to SfSparkline.


    Add namespace of ViewModel class in your XAML page if you prefer to set BindingContext in XAML.

    <ContentPage xmlns=""
                 x:Class=" SparklineDemo.MainPage"
    this.BindingContext = new ViewModel();

    Populate Sparkline with data

    Import the SfSparkline namespace as shown below in your respective page,

    using Syncfusion.SfSparkline.XForms;

    Bind the Data property of the above ViewModel to the SfSparkline.ItemsSource property as shown below.


    You need to set YBindingPath property, so that SfSparkline would fetch values from the respective property in the data model to plot the Sparkline.

    <sparkline:SfLineSparkline ItemsSource="{Binding Data}" YBindingPath="Performance"> 
    </sparkline:SfLineSparkline >
    SfLineSparkline lineSparkline = new SfLineSparkline(); 
    lineSparkline.YBindingPath = "Performance";
    lineSparkline.SetBinding(SfSparklineBase.ItemsSourceProperty, "Data");

    Xamarin forms Sparkline getting started

    You can find the complete getting started sample from this link.

    See also

    How to resolve SfSparkline not rendering issue in iOS and UWP