37
Windows Phone 7 A through the wall introduction

Windows Phone 7

Embed Size (px)

DESCRIPTION

Windows Phone 7 explained.

Citation preview

Windows Phone 7 A through the wall introduction

Overview

► What is windows phone

► Developing applications

► Designing applications

► Services (If time allows)

What is Windows Phone?

Hardware

Lumia 800

CPU 1.4 GHz single

Memory 16GB/512mb/512mb

Display 3.7” 480x800 AMOLED

General

► Unified minimum hardware specifications

► OS fit for hardware -> Agile user experience

Developing applications for

Windows Phone

Developing for Windows Phone

► Developing applications

– Silverlight

• Application types

• XAML

• Controls

• Silverlight for Windows Phone Toolkit

• Container controls

• Databinding

• Phone integration

– XNA (optional)

– Application life cycle

– Multitasking

XAML

► Design using eXtensible Application Markup Language (XAML)

► Most basic element is shape

► Transformations, Brushes and Animations

► Styling

► Avoid naming elements unless needed by code or databindings

XAML Transformations

► 4 (+1) Transformations

– Rotation

– SkewTransform

– ScaleTransform

– TranslateTransform

► Foremost used on groups of shapes

XAML Brushes

► 5 different brushes

– SolidColorBrush

– LinearGradientBrush

– RadialGradientBrush

– ImageBrush

– VideoBrush

XAML Animations

► Based on storyboards

► Allows binding of numeric properties

XAML Animations – The storyboard

► Define all partial animations related in a storyboard.

XAML Animations – Preparing the target

► Set the name of te target element and add an event handler

XAML Animations – Handle the event

► In the code we simply start the storyboard

XAML Styling

► Define styles for certain control or element types

► Styles may cascaded

► Styles may be based on other styles without redeclaring the base style

XAML Styling example

Controls

► Silverlight for Windows Phone SDK 7.1 contains a set of basic controls

– Button

– Checkbox

– HyperlinkButton

– ListBox

– PasswordBox

– ProgressBar

– RadioButton

– RichTextBox

– Slider

– WebBrowser

– TextBox

Controls continued

► Silverlight for Windows Phone Toolkit

► Separate download

– AutoCompleteBox

– ContextMenu

– DatePicker

– TimePicker

– ListPicker

– LongListSelector

– PerformanceProgressBar

– ToggleSwitch

– ExpanderView

– PhoneTextBox

– WrapPanel

Container controls

Layout container Description Multiple children

Grid Table-like layout of columns

and rows

Yes

StackPanel Horizontal or vertical

stacking of elements

Yes

Canvas Position based layout Yes

ScrollViewer Scrollable container No

Border Simple border around

elements

No

Data binding

► Works by a data binder

► Binds to any type of object

Data binding modes

Type Description Example

OneTime Pulls data from a source once <TextBox Text=”{Binding Name,

Mode=OneTime}”>

OneWay (Default) Pulls data from a

source. As data changes

these may be pulled to control

<TextBox Text=”{Binding Name}”>

TwoWay Pulls data from source and

pushes back changes

<TextBox Text=”{Binding Name,

Mode=TwoWay}”>

Data binding OneTime/OneWay example

Source Binding Control

Any object (e.g. Game

class or collection)

Any Framework Element

(e.g. TextBox, image,

etc.

Data binding TwoWay example

Source Binding Control

If data changes, notifies

Binding through

INotifyPropertyChanged

Interface

I notified of change,

rereads Source’s data

Checks the source for

INotifyPropertyChanged

Data binding example – Contact list

► We will create a basic ListBox as container for our contacts in the markup file

► Create a data template and create a text box for contact data we want to display

using binding

Data binding example – Contact list

► In the code behind file, we create a contact class containing the fields we want

to bind to, namely Name, Phone and BirthDay

Data binding example – Contact list

► In the code behind file, we then retrieve all contacts in the contructor. All calls to

phone functionallity is performed asynchronously. When the search is done we

create an INumerable of ContactInfo and set our ListBox ItemSource to use it.

Phone integration

► Two ways of interaction with phone functionallity

– Direct access to things like accelerator, vibrator, camera, playback, recording and

contacts and appoinments as seen in the data binding example.

– Via tasks by using launchers or choosers

Phone integration

► Launchers simply throws the user to another part of the phone experience, for

example:

– Dial a number

– Display a location on bing (of course, is there any alternative?) map

– Share status with a media application

► Choosers takes the user to an application and returns with data, for example:

– Choose an adress from adress book

– Return a picture from the camera and return it to the app

– Choose a photo from the gallery

Phone integration examples

► Launchers simply throws the user to another part of the phone experience, for

example:

– Dial a number

– Display a location on bing (of course, is there any alternative?) map

– Share status with a media application

► Choosers takes the user to an application and returns with data, for example:

– Choose an adress from adress book

– Return a picture from the camera and return it to the app

– Choose a photo from the gallery

Lunching bing map

► We’ll create a launcher that shows direction to Epsilon from home in bingmaps.

Create a button in XAML and refer to a function in code behind

► Add code behind

Choosing an image as background

► We’ll start with a StackPanel with a button. The button starts a chooser to select

background image for the StackPanel

► Markup with a button that trigger ChoosePhoto method

Choosing an image as background

► Then in code behind we create a chooser task to choose an image and to set

the background image of the StackPanel

Application life cycle

Running

Deactivated

Dormant Suspended

Activated

Restarting app

• Read state

• Continue where you left off

OS Kills App

• Memory unloaded

• State preserved

Resuming should not be

noticed

App interupted

• User pressed search

• Phone call started

• Notification arrived

Being Inactivated

• Save state

• App may be unloaded

App stopped

• Thread suspended

• Still in memory

• OS may suspend if needed

User Reactivates App

• If Dormant, restart

• If Suspended, restores state

Multitasking

► Multitasking on Windows Phone is accomplished thruough the combination of

tombstoning and background agents.

► Whereas the tomstoning is an effect of the life cycle the background agents are

small pieces of code allowed to run without an user interface.

Multitasking

WP7 app

BG Agent

User init

OS init

Isolated storage XAP Files

Designing for Windows Phone

Overview

► Designing applications

– Metro and Metro chrome

– Expression Blend

– MVVM library Light