WinRT, C# & XAML

Developing a Windows 8.1 application (1/8): introduction

This article is the first in a series of eight about Windows 8.1 applications development using XAML & C#. This series is intended for Windows Store Apps developers who want to discover Windows 8.1 new features and APIs. You need to have an understanding of Windows 8 development before reading these articles.

Windows 8.1 Pro and Visual Studio 2013 Ultimate are used in this series. At the time this article was written, these tools are in preview. The relevant topics will be updated when the final version will be available.

1. Introduction
2. New controls
3. AppBar, Theme and navigation
4. Windowing
5. Search, People and Calendar contracts
6. Tiles and toast notifications with Azure
7. Speech synthesis, PDF and PlayTo
8. Windows Store and app packaging

Introduction

On June 26th, Steve Ballmer officially announced Windows 8.1 preview during /Build 2013. Available by the end of the year, this update brings lots of new cool features for users and developers. This starts with the new start screen, more simple and intuitive, with the addition of new tile sizes (wide and small), new ways to interact and customize these elements, and a fresh new apps view.

More than ever, Windows 8.1 runs on any screen, at any size. View states (snapped and filled modes) does no longer exist. You can now snap more than two apps side by side and resize them the way you want. You can also use multiple monitors to display several windows of the same Windows Store App.

 

w81_intro_1

 

From a developer point of view, Windows 8.1 brings more than 5 000 new WinRT APIs. Here is a non-exhaustive list of what these new APIs include:

The diagram below shows a list of:

 

w81_intro_2

 

In this series, I will cover some of the most important features of Windows 8.1. As it won’t be a quick start guide, you need to have an experience with Windows Store app development prior to reading these articles. Every sample are written in XAML and C#.

This series is a continuation of this other series (in French) I wrote a year ago.

Prerequisites

Since these articles are targeted at developers, I’ll give you a lot of code snippets. If you want to use them, you’ll need:

Let’s start!

Project templates

Visual Studio 2013 offers two new project templates for Windows 8.1 applications:

 

w81_intro_3

 

The other project templates have not changed.

Project structure – Common folder changes

Project structure hasn’t really changed. Windows 8.1 projects still include Properties, References and Assets folders, pfx and appxmanifest files. However, the Common folder content has changed. As a reminder, this folder contains some helpers for navigation, binding, states management, and some XAML resources in a dictionary. Some of these helpers have been removed, while some others have been updated or added.

Removed files:

 

w81_intro_4

 

Added files:

The Basic Page item template has been affected by these changes. It now looks like this:

 

public sealed partial class BasicPage1 : Page
{
	private NavigationHelper navigationHelper;
	private ObservableDictionary defaultViewModel = new ObservableDictionary();

	public ObservableDictionary DefaultViewModel
	{
		get { return this.defaultViewModel; }
	}

	public NavigationHelper NavigationHelper
	{
		get { return this.navigationHelper; }
	}

	public BasicPage1()
	{
		this.InitializeComponent();

		this.navigationHelper = new NavigationHelper(this);
		this.navigationHelper.LoadState += navigationHelper_LoadState;
		this.navigationHelper.SaveState += navigationHelper_SaveState;
	}

	private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
	{
	}

	private void navigationHelper_SaveState(object sender, SaveStateEventArgs e)
	{
	}

	#region NavigationHelper registration

	protected override void OnNavigatedTo(NavigationEventArgs e)
	{
		navigationHelper.OnNavigatedTo(e);
	}

	protected override void OnNavigatedFrom(NavigationEventArgs e)
	{
		navigationHelper.OnNavigatedFrom(e);
	}

	#endregion
}

 

At the top of this class, you have:

The NavigationHelper region, at the bottom of this class, contains the well-known OnNavigatedTo and OnNavigatedFrom methods, overridden from the base Page class. These methods call their equivalents in the NavigationHelper class, themselves firing the LoadState and SaveState events.

In the end, this new structure doesn’t change a lot of things for us. The concept for navigating and managing states remain the same. You just have to deal with new classes and variables.

Package.appxmanifest

The app manifest has been improved for Windows 8.1 applications. Let’s go through the different tabs.

Application UI

The top part of this tab is still used to set properties and information that describe your application: display name, default culture, supported orientations, etc.

A new setting named Minimum width has been added. It is used to specify the minimum width the app can be resized to. Remember that Windows 8.1 can now runs more than two apps side by side. The concept of a snap view no longer exists.
With Windows 8, the minimum width of an app was 320px (snapped view). With Windows 8.1, the default value is 500px. It means that, when you place apps side by side, you can’t resize them to be less than 500px wide. However, the Minimum width setting allows you to specify 320px if you believe your app deals correctly with at smaller sizes. The 320px value is also used as a compatibility mode for Windows 8.0 apps.

 

w81_intro_5

 

The Tile Update section is a new one. It allows you to specify a URI which will be polled periodically to update the application main tile. This acts as the TileUpdater StartPeriodicUpdate method. You can set the Recurrence from one of these values:

This feature will be detailed in the seventh part of this series.

 

w81_intro_6

 

With Windows 8.1, your apps can now have up to four different tile sizes:

The Visual Assets part has evolved to reflect these changes.

 

w81_intro_7

 

You can now configure:

Capabilites

The Document library capability has been removed. This may be a bug because some APIs still need this capability.

None has been added.

 

w81_intro_8

 

Declarations

The Game Explorer declaration has been removed.

Content URIs

When using a WebView in your apps, an event called ScriptNotify is raised when the control needs to pass a string to your application using JavaScript. With Windows 8.1, the URIs that can use windows.external.notify to fire the ScriptNotify event have to be included in the appxmanifest. That’s what this new tab is for.

 

w81_intro_9

 

Note that :

Packaging

Nothing changed.

What’s next?

In this first part, we’ve seen the big picture of what has changed in Windows 8.1 applications: new templates, new helpers and new features in the app manifest. In the second part of this series, we’ll explore the new XAML controls, such as the Hub, Flyout or DatePicker controls.

Part 2 : new controls

, , , ,

4 Responses to “Developing a Windows 8.1 application (1/8): introduction”

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>