This document discusses options for building apps for Windows Phone 8.1. It provides an overview of the Windows Phone platform history and the differences between using Silverlight and Windows Runtime. Key platform features only available in Silverlight are highlighted. Guidelines are provided for determining whether to use Silverlight or Windows Runtime based on the type of app being developed. The document also covers migrating existing Silverlight apps and using new APIs like file pickers, tiles, and push notifications.
9. Phone Feature Only Available in Silverlight
Lenses Support
VOIP Support
Camera Capture Task
Clipboard APIs
Lock Screen Wallpaper API
Ringtone Provider / Alarm & Reminders
Simple Sound effects (XNA)
Run Under Lock Screen
Photos Extensibility
Search Extras
23. 24
//Create the picker object
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation =
PickerLocationId.PicturesLibrary;
// Users expect to have a filtered view of their folders
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".png");
// Open the picker for the user to pick a file
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Do something with the file...
}
//Create the picker object
FileOpenPicker openPicker = new FileOpenPicker();
// Users expect to have a filtered view of their folders
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".png");
// Open the picker for the user to pick a file
openPicker.ContinuationData["Operation"] = "SomeDataOrOther";
openPicker.PickSingleFileAndContinue();
24. sealed partial class App : Application
{
...
// Property to store the args on a File Picker activation
public FileOpenPickerContinuationEventArgs FilePickerContinuationArgs { get; set; }
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_ContractActivated(object sender, IActivatedEventArgs e)
{
var filePickerContinuationArgs = e as FileOpenPickerContinuationEventArgs;
//Event args is of type FileOpenPickerContinuationEventArgs so execute share target behavior
if (filePickerContinuationArgs != null)
{
this.FilePickerContinuationArgs = filePickerContinuationArgs;
}
}
25. public partial class ProfilePage : PhoneApplicationPage
{
...
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var app = App.Current as App;
if (app.FilePickerContinuationArgs != null)
{
this.ContinueFileOpenPicker(app.FilePickerContinuationArgs);
}
}
public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
{
// Same as in Windows XAML example...
...
}
29. 30
MPNS MPNS WNS
MPNS WNS
or
? ?
WNS is better!
• Notifications delivered
within 5 seconds to
devices connected to a
network
• No more certifications to
manage: WNS uses OAuth
instead of SSL certification
• Convergence with
Windows Store Apps
• Many improved features
compared to MPNS
33. 34
private async void PinAndUpdate_Click(object sender, RoutedEventArgs e)
{
// Create the original Square150x150 tile
var tile = new SecondaryTile(SCENARIO1_TILEID, "Scenario 1", "/MainPage.xaml?scenario=Scenario1",
new Uri("ms-appx:///Assets/originalTileImage.png"), TileSize.Default);
tile.VisualElements.ShowNameOnSquare150x150Logo = true;
await tile.RequestCreateAsync();
// When a new tile is created, app will be deactivated and the new tile will be displayed on the start screen.
// Any code after the call to RequestCreateAsync is not guaranteed to run.
// For example, updating the new secondary tile with additional data
// If the app is deactivated before reaching this point, the following code will never run.
// Update the tile we created using a notification.
var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);
...
updater.Update(notification);
}
34. 35
public partial class App : Application
{
/// <summary>
/// This delegate is invoked during Deactivate when a new tile is pinned.
/// It's important to set this property before calling SecondaryTile.RequestCreateAsync()
/// </summary>
public static Action OnNewTilePinned { get; set; }
...
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
if (OnNewTilePinned != null)
{
OnNewTilePinned();
OnNewTilePinned = null;
}
}
...
42. App Type Framework
New App WinRT or Silverlight
Existing Windows Store App WinRT
Lock Screen Image (social, weather, sports, ..) Silverlight 8.x
Camera Based App (lenses integration) or VOIP Silverlight 8.x
Music App Silverlight 8.0 or WinRT
Existing Silverlight Phone Apps Silverlight 8.x or WinRT