HTML and CSS Reference
In-Depth Information
Choosing the data format
To be a share source provider, your application doesn't need to be written in a special way. It only
needs to use a set of ad hoc components, such as the DataPackage and the DataTransferManager
objects. The former defines the package with the data to share; the latter passes the package on to
requesting applications.
When it comes to sharing data, the primary aspect to consider is the format of the data, whether
plain text, HTML, or perhaps bitmaps. Ideally, the more formats you support, the more your
application can share. In the end, though, the best choice is just supporting the formats that make the
most sense for the specific application. These formats are usually just one or two. Table 9-4 lists the
supported data formats.
TABLE 9-4 Supported formats for shared data
Data format
Plain text
Shared data consists of a plain string of text.
Shared data consists of a link to a URL that receivers may render
as a clickable item.
Shared data consists of HTML markup including styles, script,
and images.
Rich text format
Shared data consists of text formatted as RTF (such as, data you
get from Microsoft Word).
Shared data consists of an in-memory image.
Shared data consists of files.
The data package
The column Method in Table 9-4 just refers to the methods available on the DataPackage object that
allow sharing data in a particular format. Creating a valid data package is the primary responsibility of
the Share Source application. A DataPackage object can contain data in one or more of the formats
listed in Table 9-4. It is up to the requesting application to pick up data in the format that makes the
most sense.
For example, the default Windows 8 Mail application operates as a Share target. It can accept data
in a variety of formats and embeds data into the body of the email. If an application passes data as
plain text as well as HTML, the HTML format is picked up as the preferred format. You'll experiment
with this behavior in a moment.
Adding share source capabilities to TodoList
As the first step on the way to sharing data with other applications, you should register a handler
within the application for the datarequested event. You do this as soon as possible in the application
Search WWH ::

Custom Search