Must-have NuGet packages

Must-have NuGet packages

NuGet is awesome! There are so many packages though that it’s very difficult to know which ones are useful and which can be missed.
Therefore I have created a list of the NuGet packages that I find most useful when developing for Windows Phone and Windows 8. So here you go:

JSON.NET

Although JSON serialization is built-in for Windows 8 and Windows Phone 8, JSON.NET just does a better job:

It’s highly configurable. This is necessary when you want to serialize class hierarchies, apply some custom logic or basically anything that is not just standard serialization

It has support for LINQ to JSON

`PM> Install-Package Newtonsoft.Json`

##

MVVM Light

The preferred method of developing for Windows 8 and Windows Phone 8 is using Model-View-ViewModel. This package adds the following utilities to your toolbox:

A ViewModelBase-class which has properties for detecting design-mode

A RelayCommand which implements ICommand and lets you create lambdas for your commands (as opposed to subclassing ICommand for every command)

Messaging infrastructure

EventToCommand behavior

`PM> Install-Package MvvmLight`

###

Ninject

When using MVVM and developing for testing, the key is avoiding dependencies. That’s why MVVM Light comes with it’s own built-in dependency container. However, in most circumstances you need a bit more control over how your dependencies are resolved, the lifetime of your objects and partitioning certain areas in your program. That’s where Ninject comes in. Ninject has a very clear API, excellent documentation and is supported on all the different .NET platforms. For Windows Phone and Windows 8, it’s best to install the portable version as this will ensure compatibility.

`PM> Install-Package Portable.Ninject`

##

Bindable Application Bar (Windows Phone only)

The application bar in Windows Phone is an odd component. As opposed to all the other controls in the framework, the application bar is not really a Silverlight control but a native control. Because of this, databinding is not possible.
With this package you can use the application bar with databinding and have something like this:

Tombstone (Windows Phone only)

When using MVVM in Windows Phone, setting up tombstoning correctly can be cumbersome. You need to route the application and page events to your ViewModels. This package lets you control tombstoning through the use of attributes in your ViewModel. It requires minimal setup and is very easy to use.