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.
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.
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.
5 Responses to Windows 8 Conference Buddy–Be A Sharing Target