Windows Phone 7 Unleashed Session 2

28
7 Windows Phone 7 Unleashed Session II

description

Special thanks to Daniel Egan. This presentation provides a deeper dive into Windows Phone 7 for developers. Topics cover how you navigate in your applicaton, how to access Web Services, use JSON to move data, and how to push notifications.

Transcript of Windows Phone 7 Unleashed Session 2

Page 1: Windows Phone 7 Unleashed Session 2

7

Windows Phone 7

Unleashed

Session II

Page 2: Windows Phone 7 Unleashed Session 2

Session 2 Agenda

Navigation Fragment Navigation Web Services Json Deserialzation Extras Menu Push Notifications Push Notifications Helper Library Shell Tile Scheduler Cloud Phone SDK Bing Maps

Page 3: Windows Phone 7 Unleashed Session 2

Navigation

Page 4: Windows Phone 7 Unleashed Session 2

Phone Application Frame

Frame Contains Page Control and other elements

Page fills the entire content region of the frame and contains the content

Page 5: Windows Phone 7 Unleashed Session 2

Phone Application Page

A page fills the entire content region of the frame. It includes the following characteristics:

Optionally surfaces its own application bar There are three main ways to navigate between pages in your

app: Using the PhoneApplicationPage virtual methods for handling the result of

navigation. HyperlinkButton - it provides NavigateUri property which can be used to

navigate to a page Uri.

NavigationService - it provides methods, properties, and events to support navigation within a wp7 application.

Note: The PhoneApplicationPage class supports OnNavigatedTo, OnNavigatedFrom and OnNavigatingFrom virtual methods for handling the result of navigation:

Page 6: Windows Phone 7 Unleashed Session 2
Page 7: Windows Phone 7 Unleashed Session 2
Page 8: Windows Phone 7 Unleashed Session 2

A Quick Lap around the Phone• Navigation• OnNavigatedTo override• Fragment Navigation• AppBar

Demo

Page 9: Windows Phone 7 Unleashed Session 2

NameTitleMicrosoft Corporation

Connecting to Web Services

Page 10: Windows Phone 7 Unleashed Session 2

10 Microsoft Confidential

Classic Development

Forward Looking

Web + Services

Application +

Services

Oriented around multiple

devices (x Screens)

Application – Oriented

around one device

(1 Screen)

Shifting Development Strategies

Page 11: Windows Phone 7 Unleashed Session 2

Networking for Windows Phone

Support for networking features: WCF HttpWebRequest WebClient No cross-domain policy file required ODATA

Not Supported Sockets Custom WCF Bindings (no duplex) WCF RIA Services NTLM authentication

Page 12: Windows Phone 7 Unleashed Session 2

12

Simple HTTP Request

WebClient client = new WebClient();

public SimpleWebClient() { InitializeComponent();

client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);

}

private void button1_Click(object sender, RoutedEventArgs e) { client.DownloadStringAsync( new Uri("http://localhost/ServicesApplication/whatever.xml"), "sample rss");

}

void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { if (e.UserState as string == "sample rss") { this.progressBar1.Value = e.ProgressPercentage; } }

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { this.textBlock1.Text = e.Result; }

Page 13: Windows Phone 7 Unleashed Session 2

13

WCF ASMX Services

Page 14: Windows Phone 7 Unleashed Session 2

14

Restful Web Services

Use WCF Restful Services On Premise As a Azure WebRole

Data On premise In Cloud

Retrieve Lightweight rest services XML JSON

Page 15: Windows Phone 7 Unleashed Session 2

15

Using ODATA From WCF From SQL Azure From publishers – http://odata.org Odata Client Library for WP7

Page 16: Windows Phone 7 Unleashed Session 2

16

You Decide Simple Test Case : Downloaded 8 data records

Each Record had just four fields Measured bytes to transfer:

Odata version from WCF Data Services 8.5k

ASMX SOAP + Dataset - 3k REST + XML - 1.2k REST + JSON – 639bytes

Page 18: Windows Phone 7 Unleashed Session 2

18

The Extras Menu Name it Extras.xml

Page 20: Windows Phone 7 Unleashed Session 2

A Quick Lap around the Phone• Connecting to Rest Service• Using Json (Data Contract

Serializer)• Adding your app to the extras

menu

Demo

Page 21: Windows Phone 7 Unleashed Session 2

Push Notifications

Page 22: Windows Phone 7 Unleashed Session 2

Push Notification Service

Built-in support for efficient, battery-aware mobile push notifications

Managed APIs for notification-driven interaction with existing Web 2.0 sites

Windows Phone Your Web Service

Custom Web Service

Existing Web Services

Microsoft Services

Push client service

Microsoft.Phone.Notification Notification

Service

Page 23: Windows Phone 7 Unleashed Session 2

PUSH NOTIFICATIONS: DATA FLOW

Push client

Push service

Your service

Tile

App

Toast

Send push data to URI

Send push data to

client

Send URI to server

Open push channelReturn URIData to App

Data to toast

Data to tile

Event

Page 24: Windows Phone 7 Unleashed Session 2

Windows Phone Microsoft confidential.

Push Notification Service

Seattle, WA: Sunny and 85 degrees

Page 25: Windows Phone 7 Unleashed Session 2

25

Shell Tile Scheduler

Page 26: Windows Phone 7 Unleashed Session 2

26

Shell Tile Scheduler

Page 27: Windows Phone 7 Unleashed Session 2

A Quick Lap around the Phone• Push Notification Helper• ScheduleTileService

Demo

Page 28: Windows Phone 7 Unleashed Session 2

© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.

MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.