2010-07-07 70 views
5

我有一個WPF 4應用程序,我已經使用標準DragDrop.DoDragDrop方法實現了拖放操作,但是我使用觸摸來代替鼠標事件。WPF 4多點觸控拖放

我爲我的網XAML(即林拖動)如下:

<Grid x:Name="LayoutRoot" 
     ManipulationStarting="ManipulationStarting" 
     ManipulationDelta="ManipulationDelta" 
     ManipulationCompleted="ManipulationCompleted" 
     IsManipulationEnabled="True"> 
    <!-- children in here --> 
</Grid> 

現在後面的代碼是這樣的:

private void ManipulationStarting(object sender, ManipulationStartingEventArgs e) 
    { 
     e.ManipulationContainer = this; 
     e.Handled = true; 
    } 

    private void ManipulationDelta(object sender, ManipulationDeltaEventArgs e) 
    { 
     e.Handled = true; 
     DragDrop.DoDragDrop(this, new DataObject(GetType(), this), DragDropEffects.Move); 
    } 

    private void ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) 
    { 
     //completed stuff 
    } 

當我嘗試用一​​個拖手指在已經用另一個手指拖動的情況下(例如不同的手,例如可以模擬兩個人)第二次觸摸似乎沒有正確註冊,事實上,Windows似乎認爲我的兩個手指正在嘗試縮放(如捏手勢)...

有沒有人知道一種方法來解決這個問題?

非常感謝 馬克

回答

4

對於多點觸摸,你將要使用的Windows觸摸表面工具包。它包含適用於多點觸控場景的拖放式框架。它包括一個drag-and-drop framework。該鏈接包括幾個如何操作的場景。

+0

感謝Josh,請看看 – Mark 2010-08-29 23:44:35

+0

截至2013年3月21日,Surface 2.0 SDK和Runtime可供下載,網址爲:http://www.microsoft.com/en-us/download/details。 ASPX?ID = 26716 – 2013-03-21 15:52:42

1

雖然這僅僅是一個受過教育的猜測,我會說,DragDrop.DoDragDrop()不能夠並行處理多個阻力guestures。

指數:

  • 有沒有可能通過觸摸ID的方法(這將是neccessary用於區分正在進行拖拽手勢)
  • DoDragDrop()實現是靜態
  • 的呼喚DoDragDrop()正在阻塞,直到下降發生或被取消爲止
  • 它基於OLE版本的拖放操作(未針對Win7進行更新)

但是,如果有人能糾正我這件事,我會很高興,因爲我目前還在尋找適合觸摸支持的DND API。

問候, 七