This document discusses Silverlight development for Windows Phone 7. It provides an overview of Silverlight functionality on the desktop and how it is adapted for Windows Phone 7. Key points include:
- Silverlight is a development platform for Windows Phone 7 applications, with a subset of Silverlight 3 functionality supported.
- Applications are built using XAML, C# and other Silverlight languages, and deployed as XAP files to the phone.
- Supported functionality includes controls, graphics, media, networking and core frameworks. Some capabilities are phone-specific like location services and sensors.
- The document demonstrates navigation, controls, input handling and reaching out to phone services from Silverlight applications. It also discusses push
3. Silverlight is...?
4: line of business
3: out of browser
2010
2: .NET subset for RIA 2009
2008
1: a media player
2007
4. Silverlight is...?
4: line of business
3: out of browser
2010
2: .NET subset for RIA 2009
2008
1: a media player
a development platform
2007 for Windows Phone 7
5. Silverlight development on the desktop
XAP
XAP
Manifest Assembly Resource
C#
Visual Basic
XAML
Silverlight Fx/CLR
6. Silverlight development on Windows Phone 7
Windows Phone
Marketplace
XAP
Manifest Assembly Resource
C#
Visual Basic
XAML
.NET Compact
Framework/CLR
18. physical information about the phone
where is the phone?
screen resolution?
can I alert the user?
screen orientation?
is the phone moving?
19. where is the phone?
GeoCoordinateWatcher watcher =
new GeoCoordinateWatcher(GeoPositionAccuracy.Low); // saves power
watcher.MovementThreshold = 20; // minimum of 20m - avoids noise, saves power
watcher.StatusChanged += (sender, args) =>
{
if (args.Status == GeoPositionStatus.Ready) { // ready... }
};
watcher.PositionChanged += (sender, args) =>
{
double altitude = args.Position.Location.Altitude;
double latitude = args.Position.Location.Latitude;
double longitude = args.Position.Location.Longitude;
};
watcher.Start(); // this can throw and we should call Stop() System.Device.Location.dll
20. where is that again?
CivicAddressResolver resolver = new CivicAddressResolver();
GeoCoordinate location = GetAlreadyDeterminedLocation();
resolver.ResolveAddressCompleted += (sender, args) =>
{
if (args.Error == null)
{
string line1 = args.Address.AddressLine1;
string line2 = args.Address.AddressLine2;
string city = args.Address.City;
// etc...
}
};
resolver.ResolveAddressAsync(location); System.Device.Location.dll
21. is the phone moving? can I alert the user?
AccelerometerSensor.Default.ReadingChanged += (sender, args) =>
{
if (args.Value.State == SensorState.Ready)
{
// Deltas X,Y,Z from -1 to +1 – should also check timestamp here
if (args.Value.Value.Y >= -0.5)
{
// Help! I'm falling! Not sure this will help but...
VibrateController.Default.Start(new TimeSpan(0, 0, 2));
}
}
};
Microsoft.Devices.dll
// this could throw & we should stop it at some point
AccelerometerSensor.Default.Start(); Microsoft.Devices.Sensors.dll
27. reaching out to the cloud for notifications
request
unique URI Cloud Service
MyApp
URI
HTTP POST
transmission
of this URI is Service (or Client)
“out of band” URI
with push data
28. reaching out to the cloud for notifications
Cloud Service
MyApp
HTTP POST
notification types
• raw – only to a foreground app
• toast – foreground app or as a
toast if app is not foreground
• tile – always to the tile & also to
Service (or Client)
the app if in the foreground with push data
30. reaching out to XNA functionality
XNA libraries offer additional functionality
e.g. audio capture from phone’s microphone
covered in Paul’s talk next...
31. resources
developer.windowsphone.com
Charles Petzold Preview Book
learningwindowsphone.com
Sample Chapters from O’Reilly Book
channel9.msdn.com
Windows Phone 7 Training Kit
odata library for Windows Phone 7 CTP
silverlight.net