我尝试使用ManipulationDelta event wpf实现多点触控ui(在棕色地块项目中)。但我只获得翻译价值,但从不进行规模或轮换。
我的测试代码如下:
Private Sub ScrollViewerViewModelManipulationDelta(sender As Object, e As Input.ManipulationDeltaEventArgs) Handles Me.ManipulationDelta
Dim transform As MatrixTransform = TryCast(RenderTransform, MatrixTransform)
If transform Is Nothing Then transform = New MatrixTransform(RenderTransform.Value)
Dim matrix As Matrix = transform.Matrix
If e.DeltaManipulation.Scale.X <> 1 OrElse e.DeltaManipulation.Scale.Y <> 1 Then
matrix.ScaleAt(e.DeltaManipulation.Scale.X,
e.DeltaManipulation.Scale.Y,
e.ManipulationOrigin.X,
e.ManipulationOrigin.Y)
End If
If e.DeltaManipulation.Translation.X <> 1 OrElse e.DeltaManipulation.Translation.Y <> 1 Then
'matrix.Translate(e.DeltaManipulation.Translation.X,
' e.DeltaManipulation.Translation.Y)
End If
If e.DeltaManipulation.Rotation <> 0 Then
matrix.RotateAt(e.DeltaManipulation.Rotation,
e.ManipulationOrigin.X,
e.ManipulationOrigin.Y)
End If
RenderTransform = New MatrixTransform(matrix)
If e.IsInertial Then
e.Complete()
End If
'e.Handled = True
End Sub
知道我在这里缺少什么吗?我尝试了缩放和旋转的手势,但我只能翻译...
谢谢! 斯蒂芬
答案 0 :(得分:3)
您必须在ManipulationStarted
事件处理程序中调用Manipulation.SetManipulationMode
:
private void ScrollViewerViewModelManipulationStarted(
object sender, ManipulationStartedEventArgs e)
{
Manipulation.SetManipulationMode((UIElement)sender, ManipulationModes.All);
}