HTML and CSS Reference
In-Depth Information
// This extra work is necessary ONLY if the HTML references an image.
// This is the URL of the image as in the HTML block.
You transform it in a URI object
// and store it as an in-memory stream in the DataPackage resources.
var localImage = "ms-appx:///images/todolist-icon.png";
var url = new Windows.Foundation.Uri(localImage);
var streamRef = Windows.Storage.Streams.RandomAccessStreamReference.
createFromUri(url);
request.data.resourceMap[localImage] = streamRef;
}
You retrieve the HTML block as a string by reading the content of the innerHTML property of
the DIV element. The raw HTML must be formatted to comply with Windows 8 requirements. This is
accomplished by the createHtmlFormat helper method. Finally, you call setHtmlFormat to package the
HTML description of the task.
If the HTML references one or more images, then some extra work is required. In particular, images
must be referenced using an ad hoc protocol—the ms-appx protocol. This protocol identifies images
as a native part of the application. In other words, if you want to include an image that belongs to
the resources of the application, then you must use the ms-appx protocol. If you intend to reference
images from remote URLs, then using the HTTP protocol is fine. In the example above, todolist-icon.
png is an image file stored in the images folder of the application's project.
Figure 9-11 shows the content of the email used to share the task.
FIGURE 9-11 Sharing a task as HTML.
Search WWH ::




Custom Search