Sharing complex data schemas makes for richer sharing between Windows 8 Metro Style Apps


I recently wrote a post where I delved into the Windows 8 Charms for LOB apps.  I spent some time talking about using the Search charm to not only look for data on your Windows 8 device/computer, but to also search into data for Metro apps that is either stored offline or in back end systems.  This capability is very useful for LOB Metro apps to utilize as it unifies the search experience for your users.

I also spent time talking about the Share Charm and using the Share Contract to allow Metro apps to either expose certain data a user may want to share, or to allow them to consume data from another app the user is using.  Today I want to dive into this further as this powerful feature can really help create some wonderful user experiences for LOB apps.

In my last post, I pointed out the 7 types of data that can be shared between Metro Style apps:

  • Plain text
  • URIs
  • HTML
  • Formatted text
  • Bitmaps
  • Files
  • Custom data formats

While the first 6 are quite useful and likely encompass many of the share scenarios a user is seeking, it is the last one that allows complex data to be exchanged between applications.  For example, let’s assume one is working in banking and spends much of their time in a banking customer relationship management application.  This application could allow the user to see information and alerts about their regular customers.  Let’s say the app looks like the rudimentary one below:




Let’s say the Mr. Smith is on the phone with the user and wants to take out a new loan.  Since this is a CRM app, it doesn’t have the functionality to start a new loan application.  Instead, the user must navigate to the loan Metro Style app and begin the process of taking down all of Mr. Smith’s details for the loan, many of which are in this very CRM app.  Compounding this, the Loan app is written by another software vendor and the 2 ISVs have never worked together to integrate their apps.  This is where using a common schema can come into play.

In this example, the Person schema from can be used to share from the CRM app to the Loan app the general contact details about Mr. Smith.  Details on this schema can be found at  So let’s step through what needs to happen to allow this data format to be shared.

As with the more common Share types, one needs to set up the app to share it’s data.  In this case the app will share a data in the Person schema format.  First the page much instantiate an instance of the DataTransferManager and register an event to fire when the user invokes the Share Charm by clicking or tapping it (or manually using Window-H):

private void ShareSourceLoad() 
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.DataRequested);


Next, we wire up the DataRequested event to populate a JSON object with the Person Schema:

private void DataRequested(DataTransferManager sender, DataRequestedEventArgs args) 
DataRequest request = args.Request;
request.Data.Properties.Title = "Share a Person";
request.Data.Properties.Description = "Sharing contact details about a person.";

// Choose the selected item
PersonDataItem pdi = (PersonDataItem)itemListView.SelectedItem;

JsonObject person = new JsonObject();
person.SetNamedValue("type", JsonValue.CreateStringValue(""));

JsonObject personProperties = new JsonObject();
personProperties.SetNamedValue("givenName", JsonValue.CreateStringValue(pdi.Title));
personProperties.SetNamedValue("familyName", JsonValue.CreateStringValue(pdi.FamilyName));
personProperties.SetNamedValue("birthDate", JsonValue.CreateStringValue(pdi.BirthDate));
personProperties.SetNamedValue("telephone", JsonValue.CreateStringValue(pdi.Telephone));

// Continue adding name/value pairs

person.Add("properties", personProperties);

request.Data.SetData("", person.Stringify());


If we run the app and choose a customer, then invoke the Share charm, we will get the following screen:



Notice the Share Dialog on the right of the screen tells us the Title and Description of the Share.  But it also tells us we don’t have any apps that accept this type of shared content.  In this case, there are no apps on the system that have declared that they can be a Share target for type  We will go into setting up an app to accept that type in my next post.

Important links: