2016-07-07 5 views
0

現在、Windows Phone 8用の古いゲームをWPF/SilverlightでUniversal Windows Platformに移植しています。 MouseDragElementBehaviorクラスを使用してキャンバス内を移動できる文字を作成しました。このクラスのUWPに類似点はありますか?MouseDragElementBehavior in UWP

+0

なぜManipulationDeltaイベントを試してみませんか? – Apoorv

+0

私は、uwpプロジェクトのためにwpfのような振る舞いをするはずのナゲットパッケージを見たと思います –

答えて

0

コメントには、ManipulationDeltaというイベントがあります。ここでは、あなたがそれを使用する方法である。そのような単純なよう

private void LetterA_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) 
{ 
    dragLetterA.X += e.Delta.Translation.X; 
    dragLetterA.Y += e.Delta.Translation.Y; 
} 

private void LetterB_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) 
{ 
    dragLetterB.X += e.Delta.Translation.X; 
    dragLetterB.Y += e.Delta.Translation.Y; 
} 

private void LetterC_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) 
{ 
    dragLetterC.X += e.Delta.Translation.X; 
    dragLetterC.Y += e.Delta.Translation.Y; 
} 

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <Canvas> 
     <TextBlock 
      FontSize="64" 
      ManipulationDelta="LetterA_ManipulationDelta" 
      ManipulationMode="All" 
      RenderTransformOrigin="0.5,0.5" 
      Text="A"> 
      <TextBlock.RenderTransform> 
       <TranslateTransform x:Name="dragLetterA" /> 
      </TextBlock.RenderTransform> 
     </TextBlock> 

     <TextBlock 
      FontSize="64" 
      ManipulationDelta="LetterB_ManipulationDelta" 
      ManipulationMode="All" 
      RenderTransformOrigin="0.5,0.5" 
      Text="B"> 
      <TextBlock.RenderTransform> 
       <TranslateTransform x:Name="dragLetterB" /> 
      </TextBlock.RenderTransform> 
     </TextBlock> 

     <TextBlock 
      FontSize="64" 
      ManipulationDelta="LetterC_ManipulationDelta" 
      ManipulationMode="All" 
      RenderTransformOrigin="0.5,0.5" 
      Text="C"> 
      <TextBlock.RenderTransform> 
       <TranslateTransform x:Name="dragLetterC" /> 
      </TextBlock.RenderTransform> 
     </TextBlock> 
    </Canvas> 
</Grid> 

コードが背後にある次のようになります。

これが役に立ちます。