Windows Phone Toolkit overview

The Toolkit team is proud to announce the release of the Windows Phone 8 version of the Windows Phone Toolkit. Here’s what’s new:

  • New toolkit download from CodePlex
  • Installation exclusively through NuGet (deprecated .msi download file)
  • Windows Phone 7 and Windows Phone 8 toolkits in a single package
  • New controls and features
  • Bug fixes

For those of you who are new to developing for Windows Phone, the Windows Phone Toolkit is an additional package of controls that you can use with the Windows Phone SDK to easily add useful controls to your Windows Phone app.

Installation and downloads

To install the Windows Phone Toolkit

  1. Download and install the latest NuGet package manager.
    Note: The Windows Phone 8 Toolkit package requires NuGet version 2.1. If you have an older version of NuGet and try to install the Windows Phone toolkit, you’ll receive the following error message: “The package does not contain any assembly references that are compatible with that framework.” Restart all instances of Visual Studio after you install the latest version of NuGet.
  2. Install the Windows Phone toolkit package using the following steps:
    • In Visual Studio 2012, create a Windows Phone 8.0 or a Windows Phone OS 7.1 project.
    • From the menu bar in Visual Studio, select Tools > Library Package Manager > Manage NuGet Packages for Solution.
    • Select Online in the column on the left of the Manage NuGet Packages dialog box.
    • Search for the WPToolkit package, authored by Microsoft.
    • Click Install and apply the package to your project.

      Note: Alternatively, you can click Select Tools > Library Package Manager > Package Manager Console. In the Package Manager Console, type:
      Install-Package WPToolkit

The installation adds a reference to Microsoft.Phone.Controls.Toolkit.dll to your project. It also creates the Toolkit.Content folder, which contains resources for toolkit controls. This NuGet Windows Phone package supports Windows Phone OS7.0, Windows Phone OS 7.1, and Windows Phone OS 8.0. In addition, you can install the Windows Phone Toolkit Test Framework package to integrate unit tests for your Windows Phone apps. This NuGet package supports Windows Phone OS 7.1 and Windows Phone OS 8.0.

After you have added the Windows Phone toolkit package to your Windows Phone project, you can easily add a wide range of controls, such as the AutoCompleteBox control, the WrapPanel control, and the LongListMultiSelector control.

Control Examples

To get a better understanding of the controls provided in the Windows Phone toolkit, download the source code and samples from CodePlex. After you download the sample source code, run the Windows Phone 8 sample solution. You can look through the source to get an idea of how each control is used. Here are some of the new controls in Windows Phone 8.

MapExtensions (WP8 only)
clip_image002

Various Effects/Transitions
clip_image004

CustomMessageBox
clip_image006

RatingControl
clip_image008

LongListMultiSelector – List Layout (WP8 only)
clip_image010

LongListMultiSelector – Grid Layout (WP8 only)
clip_image012

   

ExpanderView
clip_image014

ListPicker
clip_image016

HubTile
clip_image018

DatePicker
clip_image020

TimePicker
clip_image022

ContextMenu
clip_image024

ToggleSwitch Control
clip_image026

AutoCompleteBox
clip_image028

Windows Phone Toolkit Test Framework

The following steps show how you can write a simple “hello world” unit test using the Windows Phone Toolkit Test Framework:

  1. In Visual Studio 2012, create a Windows Phone 8.0 or a Windows Phone OS 7.1 project.
  2. From the menu bar in Visual Studio, select Tools > Library Package Manager > Package Manager Console.
  3. In the Package Manager Console window enter the following:
    install-package WPToolkitTestFx
    The package manager will install the WPToolkit package first. Then, it will add references to Microsoft.Phone.Toolkit.Testing.dll and Microsoft.VisualStudio.QualityTools.UnitTesting.Phone.dll. It also adds AppBar icons to the Toolkit.Content folder.
  4. At the beginning of the MainPage.xaml.cs file, add the following using statements:

    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.Phone.Testing;

  5. Replace the MainPage class in MainPage.xaml.cs file with the following code:

    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.Content = UnitTestSystem.CreateTestPage();
        }
    }

    [TestClass]
    public class HelloWorldTests: WorkItemTest
    {
        [TestMethod]
        [Description(“Test1: Always have description”)]
        public void Test1()
        {
            Assert.IsTrue(true);
        }

        [TestMethod]
        [Asynchronous]
        [Description(“Test2: Sample asynchronous test”)]
        public void Test2()
        {
            // this test executes asynchronously
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // … and then fails
                Assert.IsFalse(true);
                TestComplete();
            });
        }
    }

  6. Run the application in emulator mode. The Home page of the UnitTestSystem is launched.

    clip_image030

  7. Click the play button in the app bar to run the tests.
  8. In Visual Studio, press F5 to continue execution of the app.
  9. When the app returns focus to the emulator, click HelloWorldTests to see the results.

    clip_image032

For more information, see Stefan Wick’s video titled Expert Lessons: Top Tips for Building a Successful Windows Phone Application.

Reporting issues, discussions and sample requests

Use the following list to provide feedback: