Sharing Content in Windows Store App (XAML)


Introduction

In this article we would see how we could share content by using Windows 8 Share feature.

Charm Bar and Share Charm

The Charm Bar is a tool bar in Windows 8 Operating System that is available universally. The Charm bar contains 5 different charms (like you see in the following image).

The Charm Bar can be accessed by using following methods:

  1. Tablet/Touchpad: Swipe in from the right edge
  2. With a Mouse: Move your pointer into the upper-right or lower-right corner.
  3. Press Win + C

How Share Works in Windows 8

As you see in the following image we have two kinds of application who can have share integration. Such as Source App and Target App.

Source App would register with DataTransferManager, which fill DataPackage on Share action.

Also it completes the call with a Target App selection.

Target App would activate the content for sharing. This internally processes the DataPackage contents and finally reports as complete.

Simple URL Sharing

In this sample we would see sharing a link.

To do that we need to have an object of DataTransferManager.

We need to initialize the DataTransferManager object to the current view. Also we need to subscribe to the event DataRequested.

We need to create a DataPackage which would be validated in Target App.

Now to activate the Share option the following is used.

As you see in the following image, we are seeing 3 applications which can share a link to the world. In this sample we would choose People app.

The people app connects your live ID with other social network handlers.

If you have not configured your people app with other accounts, here is how you could achieve this. Open the People app from the Start.

If you are connected to Microsoft account then you would something like this on the top-right corner. Click on it to add other account.

As you see, you are offered with these many types of accounts. In this sample we would connect to Facebook account.

As soon as your connection is established with the type of account you have chosen; the account icon would be visible.

Now we would click on the share button to share the content.

The share feature gives you a preview before sending the content. As you see in the below image; the content is prefixed with a message, which is again optional. Click on the Send button to share the content.

And in Facebook the content would look like following.

Hope this article helps, thanks for reading.

About these ads