ShareOperation ShareOperation ShareOperation ShareOperation ShareOperation Class

Definition

Handles the bulk of the work during a share operation. This includes the data that the user wants to share, setting or removing QuickLinks, and informing the system about the status of the operation.

public : sealed class ShareOperation : IShareOperation, IShareOperation2, IShareOperation3
struct winrt::Windows::ApplicationModel::DataTransfer::ShareTarget::ShareOperation : IShareOperation, IShareOperation2, IShareOperation3
public sealed class ShareOperation : IShareOperation, IShareOperation2, IShareOperation3
Public NotInheritable Class ShareOperation Implements IShareOperation, IShareOperation2, IShareOperation3
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following example shows how to work with the ShareOperation object.

var shareOperation = eventObject.detail.shareOperation;
if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) {
    shareOperation.data.getTextAsync().done(function (text) {
            // To output the text using this example, 
            // you need a div tag with an id of "output" in your HTML file.
            document.getElementById("output").innerText = text;
        }, function (e) {
            displayError("Error retrieving Text format: " + e);
        }
    });
}

Remarks

When a user selects your app as the target of a share action, an activated event fires. The object that this event sends to your app contains the instance of the ShareOperation class.

An app currently open as a Share target cannot initiate an additional ShareOperation, or launch a FileOpenPicker or FileSavePicker.

All ShareOperation APIs should only be called after the CoreWindow for the Share target has been activated. The Share platform creates an entry for share operation only after the window has been activated.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

Properties

Contacts Contacts Contacts Contacts Contacts

Gets the contacts for the share operation.

Data Data Data Data Data

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

QuickLinkId QuickLinkId QuickLinkId QuickLinkId QuickLinkId

A string that contains the ID of a QuickLink.

Methods

DismissUI() DismissUI() DismissUI() DismissUI() DismissUI()

Closes the share pane.

RemoveThisQuickLink() RemoveThisQuickLink() RemoveThisQuickLink() RemoveThisQuickLink() RemoveThisQuickLink()

Removes the QuickLink from the list of QuickLinks that are available to the user.

ReportCompleted() ReportCompleted() ReportCompleted() ReportCompleted() ReportCompleted()

Specifies that the sharing operation is complete.

ReportCompleted(QuickLink) ReportCompleted(QuickLink) ReportCompleted(QuickLink) ReportCompleted(QuickLink) ReportCompleted(QuickLink)

Specifies that the sharing operation is complete. A QuickLink that the system can save as a shortcut for future sharing operations is included.

ReportDataRetrieved() ReportDataRetrieved() ReportDataRetrieved() ReportDataRetrieved() ReportDataRetrieved()

Specifies that the app has acquired the content that the user wants to share.

ReportError(String) ReportError(String) ReportError(String) ReportError(String) ReportError(String)

Specifies that an error occurred during the sharing operation.

ReportStarted() ReportStarted() ReportStarted() ReportStarted() ReportStarted()

Specifies that the app has started to acquire the content that the user wants to share.

ReportSubmittedBackgroundTask() ReportSubmittedBackgroundTask() ReportSubmittedBackgroundTask() ReportSubmittedBackgroundTask() ReportSubmittedBackgroundTask()

Specifies that the app has requested that the system allow the sharing operation to run as a background task.

See Also