If you are interested in developing applications in the metro-style under Windows 8, you probably already know that the life cycle of these applications is closer to the life cycle of applications on Windows Phone. This means that the application is not actually executed when the user does not see it. Thus, the question arises how applications can interact with each other and the system.
In Windows 8, for metro-style applications, contracts are used to interact with each other, and extensions are used to interact with the system.
There are a lot of various contracts and extensions. To write a post about what contracts and extensions are available to the developer, I was prompted by the article Windows 8. Contract “search” in detail , after which I decided to systematize my knowledge and collect in one place brief, literally several lines, “how to” by most contracts and extensions, with examples from the Windows SDK Samples . ')
So let's get started. Let's start with the contracts.
Contracts:
App to App Picking - the ability for one application to directly select files that another application provides;
How to implement File Open Picker Contract: 1) add the File Open Picket Contract (Add Item) element to the project; 2) process FileOpenPickerActivated; 3) use FileOpenPickerUI.
How to implement File Save Picker Contract: 1) define in the manifest; 2) handle FileSavePickerActivated; 3) use FileSavePickerUI.
Cached File Updater - the ability to manage remote content caching by a local application, as well as updating locally modified cached content to a remote server;
How to implement support for caching with the update: 1) define in the manifest; 2) register for the FileUpdateRequested event; 3) handle file update requests; 4) requires support from the remote server.
Play To - implementation of the playback of the content of your application on an attached DLNA-compatible device;
Settings - the ability to provide user access to context-sensitive settings in a standard system metro view;
How to implement the contract Settings: 1) define in the manifest; 2) subscribe to the CommandRequested event of the SettingsPaneView object; 3) register your teams; 3) implement the command handler (s).
Share is a simple way to provide or receive the content of your application to another application or service. You can give / receive: text, URI, Bitmap, HTML, RTF and StorageItems
How to Share Target: 1) add the “Share Target Contract” element to the project (Add Item); 2) add a declaration to the manifest; 3) implement UI receiving
Account Picture Provider - your application will be listed in the list that provides a picture in the control panel
How to implement the Account Picture Provider: 1) add an entry to the manifest; 2) in the OnActivated handler, work out activation via the protocol with the ms-accountpictureprovider scheme; 3) display the selection interface; 4) set the selected image through UserInformation.SetAccountPicturesAsync.
Camera Settings - the application can provide a special interface for setting up the camera and effects when taking pictures and videos
How to implement the Camera Settings contract: 1) add a definition to the manifest; 2) in the OnActivated application handler, test activation by ActivationKind.CameraSettings; 3) implement the necessary settings.
Contact Picker - the application will be shown in the list of applications that are displayed when selecting contacts
How to implement the Contact Picker: 1) make a definition in the manifest; 2) in the OnActivated handler, work out the activation type of ActivationKind.ContactPicker; 3) use ContactPickerUI to display a list of contacts.
Game Explorer - to register a program in the system, like a game, a developer needs to “support” this extension and create a Game Definition File. The process is described in more detail at the link Creating a GDF file.
Print Task Settings - the program can provide advanced options for setting up a print task.
How to implement the Print Task Settings extension: 1) add a definition to the manifest; 2) handle the OnActivated event with the ActivationKind.PrintTaskSettings type.
Protocol Activation - the ability to register a protocol and / or handler to it
How to implement the Protocol Activation extension: 1) add a definition to the manifest; 2) handle the OnActivated event for the ActivationKind.Protocol type.
SSL / Certificate - this extension allows you to install digital certificates along with your application. To do this, add the appropriate settings and certificate to the manifest.
If you want to try to implement any contract or extension right now, then to start developing applications for Windows 8, you need to install free development tools on Windows 8 .