Share via

ShareOperation Class


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)]
public sealed class ShareOperation
Public NotInheritable Class ShareOperation
Object Platform::Object IInspectable ShareOperation

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)


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

var shareOperation = eventObject.detail.shareOperation;
if ( { (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);


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.


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



Gets the contacts for the share operation.


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


A string that contains the ID of a QuickLink.



Closes the share pane.


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


Specifies that the sharing operation is complete.


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


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


Specifies that an error occurred during the sharing operation.


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


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

Applies to

See also