RequestedOperation | requestedOperation property

DataPackage.RequestedOperation | requestedOperation property

Specifies the DataPackageOperation (none, move, copy, or link) for the operation.

Syntax


var requestedOperation = dataPackage.requestedOperation;
dataPackage.requestedOperation = requestedOperation;

Property value

Type: DataPackageOperation

The operation requested by the source app.

Remarks

This property specifies the operation the consumer of a data package should perform in clipboard or drag and drop scenarios. The supported options are specified in the DataPackageOperation enumeration.

When implementing clipboard functionality, DataPackageOperation.Move corresponds to the "Cut" command and DataPackageOperation.Copy to "Copy" command. It is the target of the operation's responsibility to respect this value and report that they performed a cut or copy by calling DataPackageView.ReportOperationComplete with the appropriate value.

In drag and drop scenarios, CoreDragOperation.AllowedOperations should specify the complete set of operations the source allows, and DataPackage.RequestedOperation should specify the source's desired default. Users can override this choices by using SHIFT and CTRL keys. Target apps must inspect the key state to determine the operation the user has selected.

Note  CoreDragOperation.AllowedOperations is not supported in XAML. To specify more than one allowed operation in XAML, pass multiple flags to the DataPackage.RequestedOperation property instead. If you do, you should not set CoreDragOperation.AllowedOperations elsewhere. Doing so will throw an exception and reset the specified flags of DataPackage.RequestedOperation to one.
 

Normally, DataPackage.RequestedOperation property should specify only a single operation. However, in some interop scenarios (such as copying between a Universal Windows Platform (UWP) app and File Explorer), it can contain more. In this case, the target app should select the best operation (assuming keyboard modifiers have not overridden that choice).

You do not need this property for sharing operations.

Examples


// find out what the requested operation is
var operation = dataPackage.requestedOperation;

// Request a copy operation from targets that support different file operations, like Windows Explorer
dataPackage.requestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.copy;

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

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

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

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

Namespace

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

Metadata

Windows.winmd

See also

DataPackage
DataPackageOperation

 

 

Show:
© 2016 Microsoft