UIElement.StartDragAsync(PointerPoint) 方法

定義

啟始拖放作業。

public:
 virtual IAsyncOperation<DataPackageOperation> ^ StartDragAsync(PointerPoint ^ pointerPoint) = StartDragAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<DataPackageOperation> StartDragAsync(PointerPoint const& pointerPoint);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<DataPackageOperation> StartDragAsync(PointerPoint pointerPoint);
function startDragAsync(pointerPoint)
Public Function StartDragAsync (pointerPoint As PointerPoint) As IAsyncOperation(Of DataPackageOperation)

參數

pointerPoint
PointerPoint

使用者與畫面互動的指標座標,以及拖曳視覺效果的附加位置。

傳回

DataPackageOperation值,指出拖放作業的類型,以及作業是否成功。

屬性

範例

此範例示範如何在Image元素上處理PointerPressed事件,以起始拖曳作業。

<Image x:Name="myImage" Source="ms-appx:///Assets/Logo.png" 
       PointerPressed="myImage_PointerPressed" />
private async void myImage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    var pointerPoint = e.GetCurrentPoint(sender as UIElement);
    var dropStatus = await myImage.StartDragAsync(pointerPoint);
    if (dropStatus == DataPackageOperation.Move)
    {
        // App specific code for a "move" operation.
    }
}

備註

如果您實作自訂手勢偵測來起始拖曳作業,您可以呼叫 StartDragAsync 方法,以程式設計方式在任何 UIElement上起始拖曳作業。 呼叫此方法會導致 引發 DragStarting 事件。 處理 DragStarting 事件以指定作業的其他屬性,例如資料封裝和拖曳視覺效果。

pointerPoint參數是使用者使用輸入裝置與螢幕互動 (觸控、滑鼠或手寫筆) 的點。 拖曳作業期間顯示的拖曳視覺效果會附加至呼叫端提供的 PointerPoint中所指出的指標。

此方法傳回 的 DataPackageOperation 會指出拖曳作業是否為移動、複製或連結;以及它是否成功。 這是DropCompleted事件引數中DropResult屬性所提供的相同值。

適用於

另請參閱