windows phone 7 workshop

Post on 24-Oct-2014

16 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

WP7 Developer Training

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

Speaker Profile

NGAN SEOK CHERN

Microsoft Most Valuable Professional – ASP.NET/IIS

Microsoft Malaysia

2

Windows Phone

Course Material

Slide

http://bit.ly/wEPuTn

Code

http://bit.ly/z4coxV

3

Introduction

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

new experience new platform

new design

5

Windows Phone

metro UI

6

hub

hardware

Development Tools

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

Development Platform Experience

15

Windows Phone

Application

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Windows Phone

Apps Deployment

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

Windows Phone

Apps

Free or Paid

Trial mode

Unlimited paid apps can be published

31

Windows Phone

Apps Submission in Vietnam No marketplace yet

Submission through 3rd party

Yalla Apps

App-Gateway

windows phone

marketplace 3rd party publisher apps

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

Advertising

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

Advertisement

Attract extra income from free apps

Advertisement publisher from Microsoft

Microsoft Advertising pubCenter

3rd Party advertisement publishers:

AdMob

Smaato

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

Hello Windows Phone

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Layout Control

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Silverlight for Windows Phone Toolkit

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

Silverlight for Windows Phone

Toolkit

Additional set of useful controls

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

Open source

Orientation

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

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

Input Scope

43

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Windows Phone

Configuration

Determine keyboard layout

Easy access to special characters

<TextBox InputScope="Number" ...

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

Application Bar

46

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

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; …

Windows Phone

Application Bar

48

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>

Windows Phone

App Bar & Landscape

50

Page Navigation

51

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

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

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) ); }

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(); }

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)); }

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

Isolated Storage

57

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

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

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(); }

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

Build & Deployment

61

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Marketplace Test Kit

62

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Q&A

63

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

Thank You

64

NGAN SEOK CHERN Academic Ops Program Manager | MVP ASP.NET/IIS a-seon@microsoft.com

top related