How To Create PieChart In Universal Application Development With XAML And C#

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

  1. Introduction To Universal Windows Platform (UWP) App Development Using Windows 10 And Visual Studio 2015

By reading this article, you can learn how to create Piechart 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.

Step 1 - Open Visual Studio 2015 -> Start -> New Project-> Select Universal (under Visual C#->Windows)-> Blank app -> Give the suitable name for your app (UWPPiechart)->OK.

 Blank App
Choose the Target and minimum platform version your Windows Universal Application will support. Afterwards, the project creates App.xaml and MainPage.xaml.

Step 2 - Go to the Solution Explorer and add the WINRT XAML Tool Kit Control reference in the project.

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

code

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

Browse

Accept the review change.

Review changes

Reference is added to your project.

Reference

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

namespace

Add TextBlock control, change the name and text property.

TextBlock

Step 4 - Add the Chart control code in the XAML View.

Chart control

Step 5 - Add the following namespace and class in MainPage.xaml.cs.

class

Step 6 - Add the method GetChartData() in MainPage.xaml.cs. This code is used to set the values for your Piechart and call the GetChartData() method in the constructor method (MainPage() method) in MainPage.xaml.cs.

Method

Step 7 - Deploy your app in Local Machine and the output of the UWPPiechart app is given below-

Deploy

Summary

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

Up Next
    Ebook Download
    View all
    Learn
    View all