Today is a great release day. We've launched everything you need
to write Windows Phone 7 applications. Not only that, but we've
also released XNA 4.0 not only for phone, but for all supported XNA
platforms.
Visual Studio Tools for Windows Phone 7
Today, we released the production version of the Visual Studio Tools for
Windows Phone 7. These are the only tools you'll need for
building Windows Phone 7 Applications with Visual Studio 2010 and
Expression Blend 4.
If you were working with the Beta, the very good news is that
there are not many breaking changes (see the table below) and so
upgrading should be very quick.
Please note that all of the Windows Phone for Silverlight
Developers and iPhone To Windows Phone 7 Tutorials and Videos
will be upgraded to this release within the next few days. If
you run into issues, please feel free to contact
Jesse.Liberty@microsoft.com
From the release notes, here are the breaking changes from the
beta.
Item |
Description |
Updating applications
created with earlier versions of Windows Phone Developer Tools |
Changes have been made to the
WMAppManifest.xml and template files. Now that
manifest validation has been turned on, you may need to update
these files in your older projects. A number of the changes are
listed here. However, you can also compare the
WmAppManifest.xml, app.xaml and
app.xaml.cs files in a new project to the same
files in your old projects to determine what has changed and then
update your old files accordingly.
The following list shows changes you must make to the
WmAppManifest.xml file:
- In the <App> element, change
the value of the Genre attribute from
NormalApp to apps.normal.
- In the <App> element, change
the value of the RuntimeType attribute
from SilverLight to Silverlight.
- Remove the PlaceHolderString
attribute from the <DefaultTask>
element.
- Add the NavigationPage attribute to
the <defaulttask> element and set
it to the main page of your app. For example: <DefaultTask …
NavigationPage="MainPage.xaml"/>.
The following list shows changes you must make to the
App.xaml file:
Note: The recommended option for updating this
file is to obtain a copy of the most recent version. Using your old
file, copy the information specific to your application (such as,
resources) to the new file.
- Remove the <Application.RootVisual> element
- Add the <Application.ApplicationLifetimeObjects>
element. For example:
<Application.ApplicationLifetimeObjects>
<!--Required object that handles
lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching"
Closing="Application_Closing"
Activated="Application_Activated"
Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>
The following list shows changes you must make to the
app.xaml.cs file:
- If you have added the <Application.ApplicationLifetimeObjects>
element to the App.xaml file then you will need to
add these event handlers to the app.xaml.cs
file:
private void Application_Launching(object
sender, LaunchingEventArgs e)
{
}
private void Application_Activated(object sender,
ActivatedEventArgs e)
{
}
private void Application_Deactivated(object sender,
DeactivatedEventArgs e)
{
}
private void Application_Closing(object sender, ClosingEventArgs
e)
{
}
- Add the following initialization code to your
app.xaml.cs file and call InitializePhoneApplication() in the app
constructor:
// Easy access to the root frame
public PhoneApplicationFrame RootFrame { get; private set; }
// Avoid double-initialization-
private bool phoneApplicationInitialized = false;
// Do not add any additional code to this method
private void InitializePhoneApplication()
{
if (phoneApplicationInitialized)
return;
// Create the frame but do not set it as RootVisual yet; this
allows the splash
// screen to remain active until the application is ready to
render.
RootFrame = new PhoneApplicationFrame();
RootFrame.Navigated += CompleteInitializePhoneApplication;
// Handle navigation failures
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
// Ensure you do not initialize again
phoneApplicationInitialized = true;
}
// Do not add any additional code to this method
private void CompleteInitializePhoneApplication(object sender,
NavigationEventArgs e)
{
// Set the root visual to allow the application to render
if (RootVisual != RootFrame)
RootVisual = RootFrame;
// Remove this handler since it is no longer needed
RootFrame.Navigated -= CompleteInitializePhoneApplication;
}
// Code to execute if a navigation fails
void RootFrame_NavigationFailed(object sender,
NavigationFailedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// A navigation has failed; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
#endregion
|
Limit to the number side
loading of applications on the phone |
Developer phone registration is the process
through which a registered Windows Phone® developer may unlock a
retail Windows Phone to side load applications for development and
testing. A limit on the number of side loaded applications that may
concurrently be installed on the phone will be enforced. The
default limit will be 10 applications. Attempts to side load more
than 10 applications will result in an error. This limit does not
affect applications installed via Windows Phone® Marketplace.
|
XNA Framework assembly
references |
The public key token for XNA Framework assemblies has changed.
Assembly references in content projects and game projects created
using previous releases of Windows Phone Developer Tools must be
updated to work correctly. You can do this by removing and
re-adding references that do not resolve correctly using the
References node in the Visual Studio Solution Explorer.
|
Character encoding. |
Support for all character encodings will be removed, except for
those in the following list.
- utf-8
- utf-16
- utf-16LE
- utf-16BE
- ISO-8859-1
Use of an unsupported encoding value in an application will
result in an ArgumentException exception.
You must modify existing applications to remove references to
unsupported encoding values. XML data should specify only supported
encodings. For example:
<?xml version="1.0" encoding=
"utf-8"?>.
|
A GamerPrivilegeException is returned if the user
does not have content privileges. |
If AllowProfileViewing
and AllowUserCreatedContent flags are not
set in a gamer profile, then the user cannot view profiles or
display the gamer card of another user. The following methods now
check for these privileges and will return GamerPrivilegeException if the user does not
have these privileges:
- Guide.ShowGamerCard(PlayerIndex player, Gamer gamer)
- Gamer.BeginGetFromGamertag(string gamertag, AsyncCallback
callback, object asyncState)
- Gamer.GetFromGamertag(string gamertag)
- Gamer.GetProfile()
- Gamer.BeginGetProfile(AsyncCallback callback, object
asyncState
|
The picture sharing
mechanism has changed. |
Previously, Windows Phone® 7 would
place the picture into the Isolated Storage of the application. The
picture would then be loaded when the application was launched.
Now, when the application is launched, it is passed a string token.
To retrieve the picture, the application calls the GetPictureFromToken() method, public static Picture GetPictureFromToken(string
token), which takes the token as a parameter and returns a
Picture object. You will need to update existing applications.
The following code example illustrates how to use the
GetPictureFromToken method to retrieve a photo. For more
information see, How
to: Create a Photo Extras Application for Windows Phone:
using System.Windows.Media.Imaging;
using Microsoft.Phone;
using System.IO;
using Microsoft.Xna.Framework.Media;
using System.Windows.Navigation;
.
.
.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
//Gets a dictionary of query string keys and values
IDictionary<string, string> queryStrings =
this.NavigationContext.QueryString;
//This code ensures that there is at least one key in the query
string, and checks if the "token" key is present.
if (queryStrings.ContainsKey("token"))
{
//This code retrieves the picture from the local Zune Media
Database using the token passed to the application.
MediaLibrary library = new MediaLibrary();
Picture picture =
library.GetPictureFromToken(queryStrings["token"]);
//Creates WriteableBitmap object and adds to the Image control
Source property.
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(picture.GetImage());
WriteableBitmap picLibraryImage = new
WriteableBitmap(bitmap);
retrievePic.Source = picLibraryImage;
}
}
|
Deployment and
debugging. |
While deploying or debugging, if you get the
following error: "Application could not be
launched for debugging". First, verify that the application
is installed on the target device and that there is no splash
screen in the project. Then, uninstall the application and in
Visual Studio perform the following steps:
- Add an image file with the name SplashScreenImage.jpg to the
project.
- In Solution Explorer, right-click the file and select
Properties.
- In the Properties pane, set Build Action to Content.
- Rebuild the application and redeploy it.
|
Installation on Windows
Vista. |
Windows Phone Developer Tools setup blocks
installation on Windows Vista and forces the user to install
Windows Vista SP2.
|
You can read more about the release on the Windows Phone Developer Blog.
Toolkit
Today we also released the Silverlight Toolkit for Windows Phone
7. Like the desktop toolkit, this is a way to ship out-of-band
controls and other goodies. Also like the desktop toolkit, you'll
find it at silverlight.codeplex.com
The toolkit includes a number of controls that the community has
requested:
- GestureService and GestureListener
- ContextMenu
- WrapPanel
- DatePicker
- TimePicker
- ToggleSwitch
David
Anson has put together a great blog post on the individual
bits, as have John Papa and Tim Heuer. Jesse Liberty has been creating
some great tutorials on his site as well as on silverlight.net
Want to get started with Windows Phone 7 Development yourself?
Check out the get started page on Silverlight.net
XNA 4.0
The big news on the XNA side is phone support, of course.
However, it's the full release for Windows, Xbox 360 and phone. XNA
Game Studio 4.0 is included with the Windows Phone developer
tools.
Quick Links