SmiLe SmiLe - 3 months ago 8
C# Question

How to disable "kinetic energy" of the UI object (UWP)

I have

Image
on View that I can drag. But when I release the object it is moving for some time. How I can disable this?

My
Xaml
code:

<Image Grid.Column="0"
x:Name="CollageImg1"
Margin="370,469,1665,800"
Source="{Binding CollageImg1}"
RenderTransformOrigin="0.5,0.5"
ManipulationDelta="CollageImgage1_Manipulation"
Visibility="Visible">
<Image.RenderTransform>
<CompositeTransform />
</Image.RenderTransform>
</Image>


Method that uses for moving:

private void Manipulation(ManipulationDeltaRoutedEventArgs e, Image image)
{
CompositeTransform ct = (CompositeTransform)image.RenderTransform;
ct.TranslateX += e.Delta.Translation.X;// X move
ct.TranslateY += e.Delta.Translation.Y;// Ymove
}

Answer

Remove TranslateInertia from the ManipulationMode property of the Image.

E.g. set only TranslateX and TranslateY:

<Image ManipulationMode="TranslateX,TranslateY" ... />