This presentation highlights some experiences of building a Windows Phone 7 app. It details out what you need to know when getting started along with some of the fundamental concepts of Windows Phone 7, Silverlight and XAML. It also cover some of the new features in the latest version of Windows Phone 7.5 (AKA Mango).
2. The Win Phone 7 Language
Silverlight
C#, VB .Net
XAML
XNA
3. Tools
Tools are free – App Hub
Visual Studio 2010 Express For Windows Phone
Expression Blend 4 for Windows Phone
Silverlight Toolkit – CodePlex
Download the Silverlight for Windows Phone Toolkit
4. Resources
App Hub
Windows Phone Development – MSDN
Fundamental Concepts for Windows Phone – MSDN
Good Old F1 with-in Visual Studio
5. Execution Model
• Execution Model Overview for
Windows Phone – MSDN
• No need to restore state when
app is reactivated when
returning from Dormant state.
• IsApplicationInstancePerserved
• True = Dormant
• False = Tombstoned
6. Frame and Page
Navigation
• Frame and Page Navigation
Overview for Windows Phone
– MSDN
• Frame
• Is where pages are
rendered.
• Exposes properties
from a hosted page
such as screen
orientation.
• Exposes
NavigationService.
• Reserves space for
Application Bar and
Status Bar.
7. Application
Page Model
• Application Page Model for
Windows Phone – MSDN
• A Page is a user-recognizable
collection of persistent state.
• A Screen is a something such
as a pop-up window, dialog
box or splash screen and
does not contain memorable
content.
• Pages can communicate
through simple Querystrings.
Complex objects need to be
persisted and restored from
page to page.
• Need to manage Backstack to
make sure user navigation
makes sense.
• NavigationService.BackStack
• NavigationService.RemoveBa
ckEntry
8. Orientation
How to: Handle Orientation Changes on Windows Phone
– MSDN
Like most mobile devices Windows Phone supports both
Portrait and Landscape orientations.
You need to set the supported orientation(s) on each
page by setting the Orientation property through XAML
or Code.
There are different strategies to handle orientations.
Some out of the box support if you use Stack Panels and
Scroll Views.
Alternatively you can handle the OrientationChanged
event and adjust your layout accordingly.
10. Page Layout
Grid
StackPanel
Canvas
WrapPanel
Part of Silverlight Toolkit
Others
11. Grid
Default container used when using a basic Phone
template.
You define Columns and Rows to place other controls
into.
Cells can be fixed size or have the ability to float.
Auto – Adjusts the cells size based on the content contained
with-in.
Star Sizing (*) – Indicates that the cell should take the
remaining space available in the row or column. If you have
multiple cells with asterisks you can proceed the asterisk
with a number (example 3*) to weight each one against the
others.
12. StackPanel
Controls are stacked upon each other.
Can set the Orientation property to either Horizontal or
Vertical.
If the StackPanel contains more items than can be
displayed in the view port they will be cropped.
Can wrap the StackPanel with a ScrollViewer to allow the
user to scroll to see items outside the view port.
13. Canvas
Coordinate based layout using offests, Left and Top, to
position controls with-in the Canvas.
Position 0,0 is Upper Left corner, unless of course your
FlowDirection property is set to RightToLeft.
14. WrapPanel
Works like the StackPanel except when items reach the
edge they won’t be cropped but instead wrapped to the
next row or column (depending on the Orientation).
15. Dependency Properties
Dependency Property Overview – MSDN
Applies to WPF and Silverlight.
A special property that uses a dictionary as a backing
store that keeps track of values across all instances of a
particular type.
A hierarchical relationship is built between the values.
Reduces memory foot print.
Mechanism built in to notify when a value is changed.
16. Dependency Properties – Cont.
They are often used in XAML and provide a similar
experience to how CSS works for HTML.
Allows you to specify a value at different levels:
Application Resources
Page/User Control Resources
Control Resources
Direct Properties on the Control
17. Attached Properties
Attached Properties Overview – MSDN
Are typically a special type of Dependency Property.
Are used as a way to relate controls to each other.
You essential are registering the control you want to
Attach using the property on the control you want to
attach to.
18. Setting Properties in XAML
There are two ways to set properties in XAML:
Attributes
Elements
Attributes can only accept string input.
Certain Attributes have Type converters that can take
structured strings, example being Margin where you define
the thickness of each side of the box separated by commas.
There are certain properties whose values can’t be
expressed with a simple textual value. In these cases you
can set them using the Element syntax. All properties can
be set this way but if you can set them using the Attribute
syntax there isn’t much value in using the Element syntax.
19. Data Storage
Isolated Storage Overview for Windows Phone – MSDN
Three main ways to store data:
Settings: Store data as key/value pairs by using the
IsolatedStorageSettings class.
Files and folders: Store files and folders by using the
IsolatedStorageFile class.
Relational data: Store relational data in a local database by
using LINQ to SQL.
20. Relational Data
Uses SQL Server Compact Edition
Use LINQ to SQL to work with database.
Scheme is managed through decorating classes with
special Attributes.
Table
Column
Assocation
21. Relational Data – Cont.
Adding a version column to your tables significantly
improves update performance.
If you plan to do read-only queries, after creating the
DataContext set the ObjectTrackingEnabled property to
false. This will improve performance as changes to
objects wont be tracked.
22. Relational Data – Versioning
You check your database version using the
DatabaseSchemeUpdater class.
You also use this class to submit scheme changes.
Can only make Additive changes.
If you need to make complex scheme changes you need
to create a new database and migrate the data from the
old scheme to the new scheme.
Refer to Changing the Database Scheme section in this
link for examples.
23. Relational Data – Shipping DB
How to: Deploy a Reference Database with a Windows
Phone Application – MSDN
In order to prepopulate a database with data you can either
insert the data when the app starts or build a separate app
to generate the database scheme and populate it with data.
Once populated you Use the Isolated Storage Explorer Tool
to extract the database file from your device or emulator.
You add the DB as an existing item to your project and
mark its Build Action to Content under the File Properties.
When deployed the file will live in the Reference Storage on
the device in a Read-Only state. Must copy to Isolated
Storage if you want to modify scheme or data.
24. Relational Data – Best Practices
Local Database Best Practices for Windows Phone –
MSDN
25. Device Theme Settings
Themes for Windows Phone – MSDN
When your app loads it takes a snapshot of the curremt Theme that
is setup for the device.
Background
Accent Color
Make sure to test your app by changing these Theme settings to
make sure you app looks ok. Particularly the Background colors.
To apply the Accent Color in XAML you use the "{StaticResource
PhoneAccentBrush}"
In code you use
(Color)Application.Current.Resources["PhoneAccentColor"]
To determine the Background setting from code you use:
(Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"
] == Visibility.Visible
26. Tips, Trick, & Mango
Hitting the Break key will enable the PC Keyboard in the
Emulator.
Mango added some new Advanced Features to the
Emulator.
Accelerometer
Location (Map)
Screenshots
There’s a way to enable more than one Emulator.
Long Press of Back button will bring up Application
Switching.
Only 30 Apps can register push notifications at one time.
27. Tips, Trick, & Mango – Cont.
You can test Tombstoning by going into the Projects
Properties -> Debug tab and checking the box there.
A new menu item under Debug called Windows Phone
Performance Analysis.
The WMAppManifest.xml file must contain a request for
each Capability it needs access to by adding an entry
into the Capabilities element.
Things such as Contacts, Locations, Appointments, etc.
By Default all capabilities are added, remove the items you
don’t need.
28. Tips, Trick, & Mango – Cont.
Mango added support for a Front and Back Live Tile.
In general, Tiles flip at regular intervals with each visible tile
having a different 'start' time. (...because it looks better
than all tiles flipping at the same time.)
Also, Tile flipping is suspended when the phone enters User
Idle state, to save battery life, but will restart once the user
starts using the phone again.
Live Tiles and Toaster notifications can now Deep Link
into the app.
Can go to a specific page using Querystirng parameters.
You can now create multiple Live Tiles per App using this
technique.
For Example, Pinning individual People on your Start Page.
29. Tips, Trick, & Mango – Cont.
Mango added better networking support including
support for Sockets.
Mango also added support for Background Agents, better
Multitasking.
Multitasking for Windows Phone - MSDN
Background Agents Overview for Windows Phone -
MSDN
30. Tips, Trick, & Mango – Cont.
Visual Studio has a Market Place Test Kit that allows you
to verify your App is Ready for submission.
In VS goto Project -> Open Market Place Test Kit
It helps make sure you have all your App Details setup.
Can run through the same Automated Tests the MS runs
on their end.
Can also run through their Manual Test too.
Passing these tests will greatly improve your chance of
getting your app approved. You can resolve the majority
of the issues and minimize the back and forth overhead.
31. App Submission
100 free app submissions a year.
Failed submissions and updates count towards this number.
$20 to increase the limit.
Paid apps can have a trial version.
No need for a Lite version.
API in code for checking this mode to branch your logic.
Can do beta testing with up to 100 testers.
Private link sent via e-mail.
90 days to test and provide feedback.
32. Wrapping Up
Resources
App Hub
http://create.msdn.com
Windows Phone Development
http://msdn.microsoft.com/en-us/library/ff402535(v=vs.92).aspx
Fundamental Concepts for Windows Phone
http://msdn.microsoft.com/en-us/library/ff967549(v=VS.92).aspx
Mango Jump Start
http://channel9.msdn.com/Series/Mango-Jump-Start
Contact
Jeff.Smoley@w3i.com