EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

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.

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.


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 (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

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

Metadata

Windows.winmd

See also

WebView
XAML WebView control sample

 

 

Mostrar:
© 2015 Microsoft