The Charming libraries for Windows Phone are a set of (currently) six components for Windows Phone development with the mission of providing more code consistency with Windows 8. Following on from the NFC component, this post will cover its cousin the Share component.
Windows Phone provides a number of classes in the Windows.ApplicationModel.DataTransfer namespace but there is no Share charm or sharing functionality here. The Charming Share library replicates this functionality with a sharing component which can be called in the same way as on Windows 8 and yet exposes the various platform sharing mechanisms. Because this is not an OS feature it is not possible to create share targets and share data with other apps. I am looking at the possibility of making the providers extensible so that you can add items to the list of targets.
You can currently share three types of object – Text, Uri and Image. The available targets will vary depending on the data you pass. Image is a special case as it uses the ShareMediaTask which means you have access to all the system targets including other apps registered as Photo Extras. This also means you can share an image via Email which is not possible with the EmailComposeTask. The table below shows the supported targets based on data type:-
|
Text |
Uri |
Image |
Tap+Send |
|
Yes |
Yes |
Bluetooth |
|
|
Yes |
Messaging |
Yes |
Yes |
Yes |
|
Yes |
Yes |
Yes (Individually Listed) |
Social Networks |
Yes |
Yes |
Yes (Individually Listed) |
Photo Extras |
|
|
Yes |
The Tap+Send functionality for Uris is provided by the separate Charming NFC Share component. It will only appear in the list if you add the NFC library as a reference in your project (and add the Proximity capability). The share dialog shown when passing a Uri is designed to look familiar and uses page transitions from the Phone Toolkit:-
I’m working on localised resources for these components so that they will be supported in all Windows Phone 8 languages. Because the Image sharing dialog is system provided this is already localised into the device language. In early testing the NFC and Share components are looking good with localised text and supporting LeftToRight and RightToLeft layouts.
If other formats can be supported I’m looking at the possibility of adding a Bluetooth provider to beam files using OBEX, again trying to stick as closely to the system provided Bluetooth sharing for images. Another possible target is a Clipboard provider for Text or Uri, the source code is in there but the provider is not currently used.