64
WP7 Developer Training NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Windows Phone 7 Workshop

Embed Size (px)

Citation preview

Page 1: Windows Phone 7 Workshop

WP7 Developer Training

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 2: Windows Phone 7 Workshop

Windows Phone

Speaker Profile

NGAN SEOK CHERN

Microsoft Most Valuable Professional – ASP.NET/IIS

Microsoft Malaysia

2

Page 3: Windows Phone 7 Workshop

Windows Phone

Course Material

Slide

http://bit.ly/wEPuTn

Code

http://bit.ly/z4coxV

3

Page 4: Windows Phone 7 Workshop

Introduction

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 5: Windows Phone 7 Workshop

Windows Phone

new experience new platform

new design

5

Page 6: Windows Phone 7 Workshop

Windows Phone

metro UI

6

Page 7: Windows Phone 7 Workshop

hub

Page 8: Windows Phone 7 Workshop
Page 9: Windows Phone 7 Workshop
Page 10: Windows Phone 7 Workshop
Page 11: Windows Phone 7 Workshop
Page 12: Windows Phone 7 Workshop
Page 13: Windows Phone 7 Workshop

hardware

Page 14: Windows Phone 7 Workshop

Development Tools

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 15: Windows Phone 7 Workshop

Windows Phone

Development Platform Experience

15

Page 16: Windows Phone 7 Workshop

Windows Phone

Application

Page 17: Windows Phone 7 Workshop

Windows Phone

Page 18: Windows Phone 7 Workshop

Windows Phone

Page 19: Windows Phone 7 Workshop

Windows Phone

Page 20: Windows Phone 7 Workshop

Windows Phone

Page 21: Windows Phone 7 Workshop

Windows Phone

Page 22: Windows Phone 7 Workshop

Windows Phone

Page 23: Windows Phone 7 Workshop

Windows Phone

Page 24: Windows Phone 7 Workshop

Windows Phone

Page 25: Windows Phone 7 Workshop

Windows Phone

Page 26: Windows Phone 7 Workshop

Windows Phone

Page 27: Windows Phone 7 Workshop

Windows Phone

Page 28: Windows Phone 7 Workshop

Windows Phone

Page 29: Windows Phone 7 Workshop

Apps Deployment

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 30: Windows Phone 7 Workshop

Windows Phone

Page 31: Windows Phone 7 Workshop

Windows Phone

Apps

Free or Paid

Trial mode

Unlimited paid apps can be published

31

Page 32: Windows Phone 7 Workshop

Windows Phone

Apps Submission in Vietnam No marketplace yet

Submission through 3rd party

Yalla Apps

App-Gateway

windows phone

marketplace 3rd party publisher apps

Page 33: Windows Phone 7 Workshop

Windows Phone

Marketplace Certification App-Gateway/Yalla – 1 to 3 working days to validate your

app submission entry

Marketplace – 3 to 5 working days to test and certify your app

Status will be updated at Dashboard

Your apps will be published to marketplace within 24 hours

If your apps failed certification, check error report and modify as per suggested

33

Page 34: Windows Phone 7 Workshop

Advertising

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 35: Windows Phone 7 Workshop

Windows Phone

Advertisement

Attract extra income from free apps

Advertisement publisher from Microsoft

Microsoft Advertising pubCenter

3rd Party advertisement publishers:

AdMob

Smaato

Page 36: Windows Phone 7 Workshop

Windows Phone

AdMob

Taken over by Google

Windows Phone 7 SDK in Beta

Cover a huge range of countries

Tutorial:

http://code.google.com/mobile/ads/docs/wp7/fundamentals.html

Problem:

Current Beta version contain bug that will cause you app force closed

36

Page 37: Windows Phone 7 Workshop

Hello Windows Phone

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 38: Windows Phone 7 Workshop

Layout Control

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 39: Windows Phone 7 Workshop

Silverlight for Windows Phone Toolkit

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 40: Windows Phone 7 Workshop

Windows Phone

Silverlight for Windows Phone

Toolkit

Additional set of useful controls

Download at http://silverlight.codeplex.com/

Open source

Page 41: Windows Phone 7 Workshop

Orientation

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 42: Windows Phone 7 Workshop

Windows Phone

Orientation-Aware

Tips

ScrollViewer – scroll content when in landscape

Grid/StackPanel over Canvas, since they respect layout

MinWidth/MaxWidth property values

Dynamic resizing vs hard-coded sizes

Transition animation done automatically

42

Page 43: Windows Phone 7 Workshop

Input Scope

43

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 44: Windows Phone 7 Workshop

Windows Phone

Configuration

Determine keyboard layout

Easy access to special characters

<TextBox InputScope="Number" ...

Page 45: Windows Phone 7 Workshop

Windows Phone

Supported Input Scope Default

Standard QWERTY layout

Text With autocorrect and text

suggestion

Url With .com and customized

Enter key for typing URLs

EmailSmtpAddress With .com and @ key

EmailNameOrAddress With .com and @ key, and

phone number layout

45

Maps Used to type a location to

search for on a map

TelephoneNumber 12-key layout

Search Semi-transparent layout with a

Search and .com key

NameOrPhoneNumber Standard layout with access to

phone number layout

Chat Uses intelligent features such as

abbreviations

Page 46: Windows Phone 7 Workshop

Application Bar

46

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 47: Windows Phone 7 Workshop

Windows Phone

System Tray & Application Bar System Tray

System indicator area that displays system-level status information

Apps can show/hide

Application Bar Area to display buttons for the most common

tasks

Can display pop-up menu for less common tasks

… Microsoft.Phone.Shell.SystemTray.IsVisible = false; …

Page 48: Windows Phone 7 Workshop

Windows Phone

Application Bar

48

Page 49: Windows Phone 7 Workshop

Windows Phone

Application Bar in Xaml

Automatically created for you when you create page using template

49

<phone:PhoneApplicationPage x:Class=“MyApp.MainPage” … > <phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar x:Name="AppBar" IsMenuEnabled="True"> <shell:ApplicationBar.Buttons> <shell:ApplicationBarIconButton x:Name="NewContactButton" IconUri="Images/appbar.new.rest.png" Text="New" Click="NewContactButton_Click"/> <shell:ApplicationBarIconButton x:Name="SearchButton" IconUri="Images/appbar.feature.search.rest.png" Text="Find" Click="SearchButton_Click"/> </shell:ApplicationBar.Buttons> <shell:ApplicationBar.MenuItems> <shell:ApplicationBarMenuItem x:Name="GenerateMenuItem" Text="Generate Data" Click="GenerateMenuItem_Click" /> <shell:ApplicationBarMenuItem x:Name="ClearMenuItem" Text="Clear Data" Click="ClearMenuItem_Click" /> </shell:ApplicationBar.MenuItems> </shell:ApplicationBar> </phone:PhoneApplicationPage.ApplicationBar>

Page 50: Windows Phone 7 Workshop

Windows Phone

App Bar & Landscape

50

Page 51: Windows Phone 7 Workshop

Page Navigation

51

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 52: Windows Phone 7 Workshop

Windows Phone

Frame and Page

Page control holds

section content for

the application

Frame control

contains the page

control & other

elements such as the

system tray &

application bar

Page 53: Windows Phone 7 Workshop

Windows Phone

Page Navigation

53

Silverlight on Windows Phone uses a Page-based navigation model

Similar to web page model

Each page identified by a URI

Each page is essentially stateless

private void hyperlinkButton1_Click( object sender, RoutedEventArgs e) { NavigationService.Navigate( new Uri("/SecondPage.xaml", UriKind.RelativeOrAbsolute) ); }

Page 54: Windows Phone 7 Workshop

Windows Phone

Navigating Back

54

Application can provide controls to navigate back to preceding page

The hardware Back key will also navigate back to preceding page

No code required – built-in behaviour

private void button1_Click( object sender, RoutedEventArgs e) { NavigationService.GoBack(); }

Page 55: Windows Phone 7 Workshop

Windows Phone

Passing Data Between Pages Can pass string data between pages using query strings

55

On destination page

protected override void OnNavigatedTo( System.Windows.Navigation.NavigationEventArgs e)

{

base.OnNavigatedTo(e);

string msg = string.Empty;

if (NavigationContext.QueryString.TryGetValue("msg", out msg))

textBlock1.Text = msg;

}

private void passParam_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/SecondPage.xaml?msg=" + textBox1.Text, UriKind.Relative)); }

Page 56: Windows Phone 7 Workshop

Windows Phone

Passing Objects Between Pages Often, you will need to pass a data object from one page to another

For example, the user selects an item in a list and navigates to a Details page

One solution is to store your ViewModel (that is, data) in your App class

Global to whole application

Pass the selected item index in query string

56

NavigationService.Navigate(

new Uri("/SecondPage.xaml+?Param=value" ,

UriKind.RelativeOrAbsolute

Page 57: Windows Phone 7 Workshop

Isolated Storage

57

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 58: Windows Phone 7 Workshop

Windows Phone

Isolated Storage

Use to save settings and custom data

Two type:

Data as key/value pairs

Files

Secure and sandboxed

Logical Folder Structure via APIs

No quota currently

Be responsible and inform/empower user

Reference: http://msdn.microsoft.com/en-us/library/ff402541(v=vs.92).aspx

Page 59: Windows Phone 7 Workshop

Windows Phone

Working with Key/Value Pairs Common use methods of IsolatedStorageSettings:

Add: Adds an entry to the dictionary for the key/value pair.

Contains: Determines whether the dictionary contains the specified key.

Remove: Removes the entry with the specified key.

59

private void btnSaveSetting_Click(object sender, RoutedEventArgs e) { IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; // No need for a dispatcher invoke, this will be quicker. if (!settings.Contains("key1")) settings.Add("key1", txtInput.Text); else settings["userData"] = txtInput.Text; settings.Save(); }

Page 60: Windows Phone 7 Workshop

Windows Phone

Working with Files

Common use methods of IsolatedStorageSettings:

GetUserStoreForApplication: Obtains user-scoped isolated storage that corresponds to the calling code's application identity.

FileExists: Determines whether the specified path refers to an existing file in the isolated store.

CreateFile: Creates a file in the isolated store.

OpenFile: Opens a file at a specified path by using the specified sharing and access options. This method returns an IsolatedStorageFileStream object that contains the file's stream.

DeleteFile: Deletes a file in the isolated store.

DirectoryExists: Determines whether the specified path refers to an existing directory in the isolated store.

CreateDirectory: Creates a directory in the isolated storage scope.

DeleteDirectory: Deletes a directory in the isolated storage scope.

Remove: Removes the isolated storage scope and all its contents.

60

Page 61: Windows Phone 7 Workshop

Build & Deployment

61

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 62: Windows Phone 7 Workshop

Marketplace Test Kit

62

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 63: Windows Phone 7 Workshop

Q&A

63

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]

Page 64: Windows Phone 7 Workshop

Thank You

64

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS [email protected]