Share via


ShareOperation.Data Property

Definition

Contains a DataPackage object with the data that the user wants to share.

public:
 property DataPackageView ^ Data { DataPackageView ^ get(); };
DataPackageView Data();
public DataPackageView Data { get; }
var dataPackageView = shareOperation.data;
Public ReadOnly Property Data As DataPackageView

Property Value

Contains the data that the user wants to share.

Examples

The following example shows how to get the DataPackageView object from the data property. To use the code in this example, add event listener to your app to handle the activated event. Then put this code in the function that this event listener calls.

if (eventArgs.kind === Windows.ApplicationModel.Activation.ActivationKind.shareTarget) {
    shareOperation = eventArgs.shareOperation;
    if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) {
        var output = document.createElement("div");
        var shareData = shareOperation.data.getText();
        output.innerText = shareData;
        document.body.appendChild(output);
        shareOperation.reportCompleted();
    }
}

Applies to