Windows 8 Contracts and Extensions

    If you were interested in developing metro-style applications for 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. So the question is 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 a Windows 8 article . The “search” contract in detailAfter which I decided to systematize my knowledge and collect in one place short, literally in a few lines, “how to” on most contracts and extensions, with examples from the Windows SDK Samples .

    So let's get started. Let's start with the 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) handle FileOpenPickerActivated;
      3) use FileOpenPickerUI.

      How to implement File Save Picker Contract:
      1) define in the manifest;
      2) handle FileSavePickerActivated;
      3) use FileSavePickerUI.

      An example application that implements File Open and File Save Picker contracts
    • Cached File Updater - the ability to control caching of remote content by a local application, as well as updating locally modified cached content to a remote server;

      How to implement support for caching with updating:
      1) define in the manifest;
      2) register for the FileUpdateRequested event;
      3) process file update requests;
      4) requires support from a remote server.
    • Play To - implementation of playing the content of your application on an attached DLNA-compatible device;

      An example application that implements a Play To contract
    • Search - the ability to integrate with the standard search interface;

      How to implement a search contract:
      1) add the Search Contract element to the project (Add Item);
      2) implement a search results page.

      An example application that implements the Windows 8 search contract
      . The "search" contract in detail
    • Settings - the ability to provide user access to context-sensitive settings in a standard system metro view;

      How to implement the Settings contract:
      1) define in the manifest;
      2) subscribe to the CommandRequested event of the SettingsPaneView object;
      3) register your teams;
      3) implement the handler (s) of the commands.

      Sample application using integration settings
    • Share is an easy way to provide or receive the content of your application to another application or service.
      You can send / receive: text, URI, Bitmap, HTML, RTF and StorageItems

      How to make Share Target:
      1) add the "Share Target Contract" element to the project (Add Item);
      2) add a declaration to the manifest;
      3) implement the UI of receiving the

      Application, an example of the implementation of the target application for Share

      How to make the Share Source:
      1) register yourself by calling DataTransferManager;
      2) call ShowShareUI;
      3) prepare the data for transmission.

      Application, an example of the implementation of data sources for Share .

    Let's move on to the extensions.


    If you want to try to implement some kind of contract or extension right now, then to start developing applications for Windows 8 you need to install free development tools on Windows 8 .

    Also popular now: