WebView.DataTransferPackage WebView.DataTransferPackage WebView.DataTransferPackage WebView.DataTransferPackage Property



DataTransferPackage may be altered or unavailable for releases after Windows 8.1. Instead, use CaptureSelectedContentToDataPackageAsync.

Gets a clipboard DataPackage as passed to the WebView.

public : DataPackage DataTransferPackage { get; }
DataPackage DataTransferPackage();
public DataPackage DataTransferPackage { get; }
Public ReadOnly Property DataTransferPackage As DataPackage
Property Value

A clipboard data package.


The following code example demonstrates how to use this property to implement sharing support.

void SDKSample::WebViewControl::Scenario7::Share_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
	dataTransferManager = DataTransferManager::GetForCurrentView();
	dataRequestedToken = dataTransferManager->DataRequested += ref new TypedEventHandler<DataTransferManager^, DataRequestedEventArgs^>(this, &Scenario7::dataTransferManager_DataRequested);

// Data requested handler
void SDKSample::WebViewControl::Scenario7::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;
	    request->FailWithDisplayText("Nothing to share");
    dataTransferManager->DataRequested -= dataRequestedToken;
private void Share_Click(object sender, RoutedEventArgs e)
    dataTransferManager = DataTransferManager.GetForCurrentView();
    dataTransferManager.DataRequested += dataTransferManager_DataRequested;

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;
        request.FailWithDisplayText("Nothing to share");
    dataTransferManager.DataRequested -= dataTransferManager_DataRequested;
Private Sub Share_Click(sender As Object, e As RoutedEventArgs)
    dataTransferManager = dataTransferManager.GetForCurrentView()
    AddHandler dataTransferManager.DataRequested, AddressOf dataTransferManager_DataRequested
End Sub

Private Sub dataTransferManager_DataRequested(sender As DataTransferManager, args As DataRequestedEventArgs)
    Dim request As DataRequest = args.Request
    Dim p As DataPackage = WebView7.DataTransferPackage

    If p.GetView().Contains(StandardDataFormats.Text) Then
        p.Properties.Title = "WebView Sharing Excerpt"
        p.Properties.Description = "This is a snippet from the content hosted in the WebView control"
        request.Data = p
        request.FailWithDisplayText("Nothing to share")
    End If
    RemoveHandler dataTransferManager.DataRequested, AddressOf dataTransferManager_DataRequested
End Sub


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.

See Also