DataPackage.ResourceMap | resourceMap property
Maps a URI to a file. Used to ensure that referenced content (such as an image) in HTML content is added to the DataPackage.
Syntax
var resourceMap = dataPackage.resourceMap;
Property value
Type: IMap<String, RandomAccessStreamReference> [JavaScript/C++] | System.Collections.Generic.IDictionary<String, RandomAccessStreamReference> [.NET]
Specifies a name/value pair that specifies the an HTML path with a corresponding StreamReference object.
Remarks
HTML content often contains references to other files. The most common example is an img tag that refers to a specific file. To ensure that the image is sent with the rest of the HTML content, you need to use ResourceMap, which maps the URI string to the actual data. You can learn more about this in How to share HTML.
Windows Phone 8
This API is not implemented and will throw an exception if called.
Examples
function shareHtmlHandler(e) { var request = e.request; var htmlExample = "<p>Here is our store logo: <img src='images/logo.png'>.</p>"; var localImage = "images\\logo.png"; request.data.properties.title = "Share Html Example"; request.data.properties.description = "A demonstration that shows how to share an HTML fragment with a local image."; var deferral = e.request.getDeferral(); Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(localImage).done(function (imageFile) { request.data.setHtmlFormat(Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat(htmlExample)); request.data.resourceMap[localImage] = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile); deferral.complete(); }, function (err) { request.failWithDisplayText(err); }); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 2/25/2013
