Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataPackage.ResourceMap | resourceMap property

Applies to Windows and Windows Phone

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.

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.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

See also

DataPackage

 

 

Show:
© 2014 Microsoft