C# – First steps with C# and .NET – part 007 .

In this tutorial, I will show you how to deal with the NuGet package, some class definition, and how to use a canvas.
First, create a new UWP project and from the main menu select Tools – NuGet Package Manager – Package Manager Console.
This will open the Package Manager Console in your Visual Studio.
Use the command Install-Package to install the Win2D package:

In the Solution Explorer tab you will see these package on References tree.
The UWP project come with many files, in this tutorial I used just these MainPage.xaml and MainPage.xaml.cs.
Open the MainPage.xaml and will see a white rectangle – this is your window application.
In the left area of Visual Studio, you have the Toolbox, also you can open it with Ctrl+Alt+X keys.
This lets you add the canvas to the default window by drag and drop operation.
The MainPage.xaml file is changed and you need to update to this source code and read all comment’s:

The next changes comes to the MainPage.xaml.cs and let you to draw on canvas.
I draw on the canvas the SVG images, an eclipse, and one text.
Let’s see the source code:

The result after building with Ctrl+Shift+B keys and running with F5 key is this:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.