Dela via


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 ref class ShareOperation sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
class ShareOperation final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
public sealed class ShareOperation
Public NotInheritable Class ShareOperation
Inheritance
Object Platform::Object IInspectable ShareOperation
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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).

Version history

Windows version SDK version Value added
1709 16299 Contacts

Properties

Contacts

Gets the contacts for the share operation.

Data

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

QuickLinkId

A string that contains the ID of a QuickLink.

Methods

DismissUI()

Closes the share pane.

RemoveThisQuickLink()

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

ReportCompleted()

Specifies that the sharing operation is complete.

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

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

ReportError(String)

Specifies that an error occurred during the sharing operation.

ReportStarted()

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

ReportSubmittedBackgroundTask()

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

Applies to

See also