ShareOperation class

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.

Syntax


public sealed class ShareOperation

Members

The ShareOperation class has these types of members:

Methods

The ShareOperation class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

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

 

Properties

The ShareOperation class has these properties.

PropertyAccess typeDescription

Data

Read-only

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

QuickLinkId

Read-only

A string that contains the ID of a QuickLink.

 

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

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);
        }
    });
}


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0 [for Xbox, see UWP features that aren't yet supported on Xbox]

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.DataTransfer.ShareTarget
Windows::ApplicationModel::DataTransfer::ShareTarget [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.DataTransfer.ShareTarget
Windows::ApplicationModel::DataTransfer::ShareTarget [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Standard)]
[Version(0x06020000)]

See also

Object
Sharing content source app sample
Sharing content target app sample
Quickstart: Sharing content (HTML)
Share data
Quickstart: Receiving shared content (HTML)
Receive data
Sharing content target app sample (Windows 10)
Sharing content source app sample (Windows 10)
App package information sample (Windows 10)

 

 

Show:
© 2016 Microsoft