Creating Line Chart Application In UWP With XAML And C#

Before reading this blog, please go through the article's link given below-

After reading this blog, you can learn, how to create Line chart in Universal Windows apps development with XAML and Visual C#.

The following important tools are required to develop UWP-

  1. Windows 10 (Recommended).
  2. Visual Studio 2015 Community Edition (It is a free software available online).

Now, we can discuss step by step app development.

Step1 - Open Visual Studio 2015 -> Start -> New Project-> Select Universal (under Visual C#->Windows)-> Blank app -> Give the Suitable name for your app (UWPLineserieschart)->OK. Choose the Target and minimum platform version for your Windows Universal application will support. Afterwards, the project creates App.xaml and MainPage.xaml.

New Project

Step 2 - Open (double click) the file MainPage.xaml in the Solution Explorer and add the WINRT XAML Tool Kit Control reference in the project.

For adding the reference, right click on your project (UWPLineserieschart) and select Manage NuGet Packages.

 NuGet Packages 

Choose Browse, search WinRTXamlToolkit.Controls.DataVisualization.UWP, select the package and install it.

Browse 

Accept the review changes.

Review changes
 
The reference is added to your project.

Reference 

Add TextBlock control, change the name and text property.

TextBlock 

Step 3 - Add the charting namespace in your XAML view.

namespace

Step 4- Add the Line series control code in XAML View.

XAML 

Step 5 - Add the name space, given below and class in MainPage.xaml.cs.

XAML

Step 6- 
Add the method GetChartData() in MainPage.xaml.cs. This code is used to set the values for your Line chart.

constructor 

Step 7- Call the GetChartData() method in the constructor method (MainPage() method) in MainPage.xaml.cs.

constructor
 
Step 8 - Deploy your app in Local Machine and the output of the UWPLineserieschart app is given below,

output 

Summary - Now, you have successfully created and tested Line chart in Visual C# - UWP environment.