在上篇文章中介绍了底层的触控编程接口,本文将讲解Silverlight for Windows Phone中的高级触控编程接口,与之相关的是定义在UIElement中的

ManipulationStarted,ManipulationDelta和ManipulationCompleted事件。

一.Manipulation相关事件

    这3个事件并不是单独来处理每个手指的触控信息的,它们将所有手指的平移和缩放操作进行了整合。由于这3个事件都是在UIElement类中定义的,都是基于具体的元素的,而非应用程序级别的事件,所以我们可以为任何UI元素添加对这些事件的处理,比如ListBox,Canvas,Rectangle等等。下面的XAML代码是在一个Rectangle元素中添加了对这3个事件的处理程序:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" Background="Transparent">
            
<Canvas x:Name="canvas" Background="Orange">
                
<Rectangle x:Name="rectangle" Width="200" Height="200"
                           Fill
="Blue" Stroke="Red" StrokeThickness="5"
                           ManipulationStarted
="rectangle_ManipulationStarted"
                           ManipulationDelta
="rectangle_ManipulationDelta"
                           ManipulationCompleted
="rectangle_ManipulationCompleted">
                    
<Rectangle.RenderTransform>
                        
<TranslateTransform x:Name="translation"/>
                    
</Rectangle.RenderTransform>
                
</Rectangle>
            
</Canvas>
</Grid>

相关文章:

  • 2021-04-15
  • 2022-02-14
  • 2022-02-02
  • 2021-10-28
  • 2021-06-02
  • 2021-07-10
  • 2022-12-23
  • 2021-06-25
猜你喜欢
  • 2021-09-22
  • 2021-11-01
  • 2021-12-01
  • 2021-06-09
  • 2022-01-01
  • 2022-01-13
相关资源
相似解决方案