Windows Phone 8
Porting Windows 8 Application to Windows Phone 8
Lab version: 1.0.0
Last updated: 11/13/2012
Contents
Overview 3
Exercise 1: Port Contoso Cookbook XAML 6
Task 1 — Create a New Phone Project and Import Common and Asset Files 8
Task 2 — Porting the Main Page 14
Task 3 — Porting the Group Detail Page 19
Task 4—Porting the Item Detail Page 24
Exercise 2: PortingContoso Cookbook Business Logic 30
Task 1 — Identify Reusable Business Logic 30
Task 2 — Port the Load Method to Windows Phone 8 32
Exercise 3: Phone-Specific Functionality 44
Task 1 — Implement Image Share in the Windows Phone 8 app 45
Task 2 — Implement Secondary Tile Pinning in the Windows Phone 8 App 47
Task 3 — Implement Reminders in the Windows Phone 8 app 54
Summary 60
OverviewThe new Windows Phone 8 operating system brings a number of new and updated features to app developers, including native game development in C++, a phone-tailored version of the Windows Runtime (WinRT), and a new kernel shared with Windows 8.
Windows Phone 8 does not require the full Windows Runtime functionality, because the Windows Runtime targets desktop PCs and tablet devices. The Windows 8Runtime has many features not relevant for Windows Phone, and these features are not available in its Windows Phone version. In addition, Windows Phone 8 provides phone-specific functionality, which resides in the Microsoft.Phone namespace (carried forward from previous Windows Phone versions). This namespace and its functionality are only relevant and available for Windows Phone 8, not forWindows 8 devices.
This lab will provide guidance of how to port Windows Store (Windows 8) apps to Windows Phone 8.
When porting a Windows Store app to the phone, you are likely to encounter compilation errors from Windows 8 APIs that are not available in the Windows Phone version of the Windows Runtime. The following issues need to be addressed:
Feature Inconsistency. Some features exist on bothplatforms but are not implemented identically. The Windows Phone app must then use the Windows Phone APIs, or modify the implementation to imitate Windows 8 functionality on the phone. For example, the Windows 8 Charms API has a different API set and design approach than the Windows Phone Share action; you will have to decide whether the Windows Phone Share action is suitable as a replacement forthe Windows 8 Share Charm.
Missing Features. Some Windows 8 features do not exist in the Windows Phone Runtime. For example, your Windows Store app might be using the GridView control that is not available in Windows Phone. In this case, you will have to use a different content control to display your data.
Orientation. The default orientation of Windows Store apps is landscape, whereas thedefault orientation of Windows Phone apps is usually portrait. This affects the app’s general layout, choice of controls, and their relative locations on the screen.
Figure 1
Windows 8 Using Landscape Orientation, Windows Phone Using Portrait Orientation
XAML. Windows Store apps use a slightly different version of XAML than Windows Phone 8. For example, namespace definitions are different androot elements might not match.
Screen Size. Windows Store apps are designed to run on 10-inch screens and larger with a minimum resolution of 1024x768, whereas Windows Phone is designed to run on up to 5-inch screens, often requiring a different layout. In addition, the choice of resolutions on Windows Phone devices is more limited than on Windows 8.
After considering these issues involved inporting a Windows Store app to Windows Phone 8, we are going to rewrite most of our app’s XAML pages and reuse only some parts the existing XAML. There is some good news, though. We can still reuse large parts of our business logic and all of our data templates, which will save us a considerable amount of work.
During the course of this lab, we will use the Contoso Cookbook sample. It is a sample...
Regístrate para leer el documento completo.