I have found this example which seams to be exactly what I need. But it does not work in an universal app.
Xaml:
<Rectangle Name="TestRectangle"
Width="200"
Height="200"
Fill="Blue"
ManipulationMode="All" />
C#:
public MainPage()
{
InitializeComponent();
// Add handler for the ManipulationDelta event
TestRectangle.ManipulationDelta += new ManipulationDeltaEventHandler((sender, e) =>
{
UIElement element = sender as UIElement;
CompositeTransform transform = element.RenderTransform as CompositeTransform;
if (transform != null)
{
transform.ScaleX *= e.DeltaManipulation.Scale;
transform.ScaleY *= e.DeltaManipulation.Scale;
transform.Rotation += e.DeltaManipulation.Rotation * 180 / Math.PI;
transform.TranslateX += e.DeltaManipulation.Translation.X;
transform.TranslateY += e.DeltaManipulation.Translation.Y;
}
});
TestRectangle.RenderTransform = new CompositeTransform();
}
Here is the error:
'Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs' does not contain a definition for 'DeltaManipulation' and no extension method 'DeltaManipulation' accepting a first argument of type 'Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs' could be found (are you missing a using directive or an assembly reference?)
How do I fix it?
According to MSDN, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs
has Delta
property instead of DeltaManipulation
. So try to replace DeltaManipulation
with Delta
:
if (transform != null)
{
transform.ScaleX *= e.Delta.Scale;
.....
.....
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.