NuGet is the package manager for .NET, UWP, Windows Forms, and WPF projects. Browse the package catalog with NuGet to install, update, or delete packages from your project.
Developers share libraries and resources by bundling their work into packages. You can pull a package into Visual Studio to provide extra functionality to projects. For example, to add support for JSON or add animation routines to XAML.
NuGet is built into Visual Studio, so you don't have to leave the IDE.
Let's use NuGet to install new XAML animation features from the Win2D package:
With the package installed, we can call a feature directly in the XAML code to define our main page.
If you get an error during installation, you might not have set the correct minimum version.
<Page
x:Class="Hello_World.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml">
<Grid>
<canvas:CanvasControl Draw="CanvasControl_Draw" ClearColor="CornflowerBlue"/>
</Grid>
</Page>
using Windows.UI;
using Windows.UI.Xaml.Controls;
using Microsoft.Graphics.Canvas.UI.Xaml;
namespace Hello_World
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.White, 3);
args.DrawingSession.DrawText("Hello world!", 100, 100, Colors.White);
}
}
}
This XAML code includes a reference to the package we installed earlier.
You should see an ellipse circling the text "Hello world!" on a blue background.