Introduction
Must-have NuGet packages
MVVM

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 faster (.NET serialization performance comparison)
  • The API is clearer (that’s a personal opinion)
  • 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:

bar:Bindable.ApplicationBar <bar:BindableApplicationBar IsVisible="{Binding BarIsVisible}" IsMenuVisible="{Binding IsMenuVisible, Mode=TwoWay}" IsMenuEnabled="{Binding IsMenuEnabled}" ForegroundColor="{Binding ForegroundColor, Converter={StaticResource DoubleToColorConverter}}" BackgroundColor="{Binding BackgroundColor, Converter={StaticResource DoubleToColorConverter}}" BindableOpacity="{Binding Opacity}" Mode="{Binding Mode}" MenuItemsSource="{Binding MenuItems}" ButtonsSource="{Binding Buttons}"> <bar:BindableApplicationBarButton Text="XAML Btn 2" IconUri="/Icons/Dark/appbar.next.rest.png" Command="{Binding TestCommand}" CommandParameter="{Binding TestCommandParameter}" /> bar:BindableApplicationBar.MenuItems <bar:BindableApplicationBarMenuItem Text="XAML MnuIt 2" Command="{Binding TestCommand2}" CommandParameter="{Binding TestCommand2Parameter}" /> </bar:BindableApplicationBar.MenuItems> </bar:BindableApplicationBar> </bar:Bindable.ApplicationBar>

`PM> Install-Package BindableApplicationBar `
##  

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.

For more information check my post Tombstoning made easy in Windows Phone MVVM

`PM> Install-Package WindowsPhone.MVVM.Tombstone`
Kenneth Truyers
View Comments
Next Post

Javascript hoisting explained

Previous Post

Portable class libraries or source code sharing?