WebView.DataTransferPackage property

This topic has not yet been rated - Rate this topic

Gets a clipboard DataPackage as passed to the WebView.

Syntax


public DataPackage DataTransferPackage { get; }

Property value

Type: DataPackage

A clipboard data package.

Remarks

This property is typically used to support sharing. During a share operation, the source app puts the data being shared in a DataPackage object and sends that object to the target app for processing.

Examples

The following code example demonstrates how to use this property to implement sharing support. The full code listing for this example is available in the XAML WebView control sample.


private void Share_Click(object sender, RoutedEventArgs e)
{
    dataTransferManager = DataTransferManager.GetForCurrentView();
    dataTransferManager.DataRequested += dataTransferManager_DataRequested;
    DataTransferManager.ShowShareUI();
}

void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
    DataRequest request = args.Request;
    DataPackage p = WebView7.DataTransferPackage;

    if (p.GetView().Contains(StandardDataFormats.Text))
    {
        p.Properties.Title = "WebView Sharing Excerpt";
        p.Properties.Description = "This is a snippet from the content hosted in the WebView control";
        request.Data = p;
    }
    else
    {
        request.FailWithDisplayText("Nothing to share");
    }
    dataTransferManager.DataRequested -= dataTransferManager_DataRequested;
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

WebView
XAML WebView control sample

 

 

Build date: 3/12/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.