The Extras menu of the built-in picture
viewer app allows you to add a link to your app so that the user can
quickly launch your app from within the picture viewer. This
effectively allows you to extend the picture viewer with your own app.
An Extras application may be used to enhance
an image’s color, crop an image, convert an image to monochrome, or
even read a photo’s Exchangeable image file format (EXIF) information
to display where the photo was taken on a map.
For an example of an app that reads EXIF
data, see the Photo Location app on the Windows Phone Marketplace.
(Full disclosure: The app is written by my wife.)
When users tap the three dots on the
application bar in the picture viewer, they see a menu containing a
link to the Extras menu (see Figure 1).
FIGURE 1 Users can activate a photo Extras application or a photo Share application.
Users selecting the Extras menu item see the list of apps that are registered as Extras applications (see Figure 2).
FIGURE 2 The sample Extras application displayed in the Extras menu.
When a user selects your app from the Extras
menu, your app is launched, and it receives an identifier (a token)
that is used to retrieve the image from the phone’s image library.
1. Adding Your App to the Extras Menu
To indicate to the Windows Phone picture
viewer that your app should be included in the Extras menu, the
inclusion of an XML file called Extras.xml is required in the root of
your XAP file.
To add the Extras.xml file to your project, follow these steps:
1. Right-click the name of your project in the Solution Explorer and select Add, New Item.
2. On the Add New Item page, select XML File; then name the file Extras.xml.
3. Select Add.
Note
Make sure that the Extras.xml file is set to
Content. Contrary to the official documentation on MSDN, the Copy to
Output Directory option should be set to Do Not Copy. You can do this
via the Visual Studio Properties window after selecting the file in the
Solution Explorer.
Edit the Extras.xml file so that it matches Listing 1.
LISTING 1. Extras.xml
<?xml version="1.0" encoding="utf-8" ?>
<Extras>
<PhotosExtrasApplication>
<Enabled>true</Enabled>
</PhotosExtrasApplication>
</Extras>
When an app is installed on the
phone, the OS scans the XAP file. When it discovers the Extras.xml
file, it adds your app to the picture viewer’s Extras menu.