(For an overview of this series, please read this post.)
Contracts and extensions are the glue that binds Metro style apps together and to the system UI as well as Windows itself. A contract is like an agreement between one or more apps. Contracts define the requirements that apps must meet to participate in these unique Windows interactions. An extension on the other hand is like an agreement between an app and Windows. Extensions lets app developers extend or customize standard Windows features primarily for use in their apps and potentially for use in other apps.
Two apps that have implemented the same contract can work together to complete a broad or complex scenario.
- For some of the most common contracts such as search, share, and file pickers, start with the corresponding Visual Studio item templates.
- Rely on charms for a consistent invocation model that users can confidently rely on. Avoid creating alternative UI on the app canvas to invoke the contracts; that could confuse users.
The three contracts you will more than likely use are the Share, Search, and File Picker contracts.
The share contracts let people share data from one app with another app. A source app is one which provides something to share, and a target app receives the shared content, using a set of common data formats.
- Every app should be a sharing source and implement the broadest set of formats possible.
- Apps that publish, store, or transform the shared data are good candidates to be a sharing target. Examples include communication, social networking, and device-connected apps.
The search contracts let people search an app’s content from anywhere in Windows. Results are provided by the app, and displayed within the app’s own UI. See Guidelines and checklist for search.
- Use the search charm in place of a custom in-app search, especially when the scope is across the app’s full content set (like searching for a product in a shopping app). Do not use search as an in-place “Find” feature, when the scope is limited to the current view (like locating a word within a document).
- Provide search suggestions to help people find something quickly.
- Provide a way to navigate between the result page and the app’s main UI.
The file picker contracts let people access an app’s content from another app. When the file picker is invoked, users can browse and select files from either the local storage or another app that supports the file picker contract.
- Leverage this contract if your app accesses or stores files that would be useful to users from another context.
- Leverage the ListView control to get the built-in fluid layout and selection behavior.
Of course these aren’t the only contracts and extensions in Windows 8. The complete list of contracts and extensions is
- Account picture provider (extension)
- App to App Picking (contract)
- AutoPlay (extension)
- Background tasks (extension)
- Cached file updater (contract)
- Camera settings (extension)
- Contact picker (extension)
- File activation (extension)
- Game Explorer (extension)
- Play To (contract)
- Print task settings (extension)
- Protocol activation (extension)
- Search (contract)
- Settings (contract)
- Share (contract)
- SSL/certificates (extension)
Next up, you need a great tile.