Registration of a file association is done in your app’s WMAppManifest.xml file. To edit the WMAppManifest.xml file, in the Visual Studio Solution Explorer, right-click the WMAppManifest.xml file, and then select View Code.
A file association is specified with the FileTypeAssociation
element. Listing 30.1 shows an excerpt from the WMAppManifest.xml file in the WPUnleashed.FileAndProtocolAssociations project.
The following elements are used to register a file association:
Extensions Element—Contains FileTypeAssociation
elements and other extension items such as Protocol
extension elements, discussed later in this chapter.
FileTypeAssociation—Defines a file association. You can register a maximum of 20 file associations for your app. The Name attribute is required and allows you to choose a friendly name for the association. The TaskID
and NavUriFragment
elements must be specified as shown.
Logos—An optional element that provides a list of logo images used by built-in apps to indicate the type of file.
Logo—An optional element that provides the path to a file in your app that is used to represent files with the extension type. There are three Logo types: small, medium, and large.
SupportedFileTypes—Lists one or more file extensions that are associated with the file type. At most, 20 file extensions can be listed for the file type.
FileType—Indicates the file extension for the file type. The file extension text should include the period (.) character.
Note
The Extensions
element must immediately follow the Tokens
element in the WMAppManifest.xml file.
In the sample, the file extension .unl has been chosen arbitrarily and is intended to represent the word “unleashed.” When the WPUnleashed.FileAndProtocolAssociations app is launched, the existence of the extension in the WMAppManifest.xml file causes the file association to be registered with the OS.
<Extensions>
<FileTypeAssociation Name="UnleashedFileType"
TaskID="_default"
NavUriFragment="fileToken=%s">
<Logos>
<Logo Size="small">UnleashedIcon33.png</Logo>
<Logo Size="medium">UnleashedIcon69.png</Logo>
<Logo Size="large">UnleashedIcon176.png</Logo>
</Logos>
<SupportedFileTypes>
<FileType>.unl</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
...
</Extensions>
You can define a set of logos (image files) that visually represent the file association of your app. These logos provide an integrated look to custom file types appearing in built-in apps.
Table 30.1 lists the three image sizes that can be defined for each file association.
Note
Although the Logo
element is optional in the WMAppManifest.xml file, if you do provide one or more Logo
elements, you must provide all three.
3.142.252.199