Telerik blogs

Yesterday, we looked at being a sharing source.  This was surprisingly easy.  Being a target would be more complex except that Visual Studio provides a template that greatly simplifies the process.

By using the template, we avoid having to set the package appxmanifest and we avoid having to muck about in App.xaml.cs.  All that work is done for us.  To see this at work, create a new application and name it SharingTarget.

Right click on the project in Solution Explorer, and choose Add –> New Item.  From the list, select Share Target Contract and use the default name.

You will be prompted that there are required files that Visual Studio can add for you.  Click Yes.

ShareTargetIncludeFiles

Wait a few seconds and you’ll see that a number of files have been added to the Common Directory and that ShareTargetPage1.xaml has been added to your solution.

That’s it! You now have a target.  The sample page provides all the needed information, including the ability to add a comment.

To see this at work, run the program once (to register it) and then stop the new target program. Remember that targets don’t have to be running to be in the target list; if the user selects your target application it will be started for you.

Return to the source application that we built yesterday and start that up.  Swipe to bring in the charms and touch the sharing charm. Notice the list of target applications now includes your new application.

ShareTargetRunning

 

If you click on SharingTarget (the application you just created) the text version of the data is picked up as our target currently only supports text (if you try Mail you’ll still see the HTML version).

Note that this new application doesn’t do anything with the data you’ve shared; you’ll have to write additional code to integrate that data into your new application.


Win8_Download (2)


jesseLiberty
About the Author

Jesse Liberty

 has three decades of experience writing and delivering software projects. He is the author of 2 dozen books and has been a Distinguished Software Engineer for AT&T and a VP for Information Services for Citibank and a Software Architect for PBS. You can read more on his personal blog or follow him on twitter

Comments

Comments are disabled in preview mode.