不使用scrollviewer进行缩放 [英] Zoom without using scrollviewer
本文介绍了不使用scrollviewer进行缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我目前正在使用可以由用户移动的多个控件的画布。如何在不使用滚动查看器的情况下允许用户放大画布?使用translate转换来缩放画布会对其上的控件执行任何操作吗?
I'm currently working with a canvas with multiple controls that can be moved by the users. How do I allow the users to zoom into the canvas without using a scrollviewer? Would using translate transform to scale the canvas do anything to the controls on it?
提前谢谢!
推荐答案
您好ChloeLee,
您可以使用GestureRecognizer API来移动,旋转或缩放元素。请参阅官方的BasicInput示例。
https:// github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BasicInput
GestureSettings GenerateDefaultSettings()
{
return GestureSettings.ManipulationTranslateX |
GestureSettings.ManipulationTranslateY |
GestureSettings.ManipulationRotate |
GestureSettings.ManipulationTranslateInertia |
GestureSettings.ManipulationRotateInertia|
GestureSettings.ManipulationScale;
}
void OnManipulationUpdated(object sender, ManipulationUpdatedEventArgs e)
{
previousTransform.Matrix = cumulativeTransform.Value;
// Get the center point of the manipulation for rotation
Point center = new Point(e.Position.X, e.Position.Y);
deltaTransform.CenterX = center.X;
deltaTransform.CenterY = center.Y;
// Look at the Delta property of the ManipulationDeltaRoutedEventArgs to retrieve
// the rotation, X, and Y changes
deltaTransform.Rotation = e.Delta.Rotation;
deltaTransform.TranslateX = e.Delta.Translation.X;
deltaTransform.TranslateY = e.Delta.Translation.Y;
deltaTransform.ScaleX = deltaTransform.ScaleY = e.Delta.Scale;
}
最好的问候,
David
Best Regards,
David
这篇关于不使用scrollviewer进行缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文