Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I display the images on canvas and I want that i move all the images. Currently I am able to move the last image which i brought on canvas. And I also want that i zoom these images.so please help me in this.

What I have tried:

C#
private TranslateTransform dragTranslation;

       // Constructor


       void Drag_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
       {
           // Move the rectangle.
           dragTranslation.X += e.Delta.Translation.X;
           dragTranslation.Y += e.Delta.Translation.Y;

       }


private void Stickers1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

var selecteditem = e.AddedItems[0] as StickersImageListModel;

{
Stickers1.Visibility = Visibility.Collapsed;
Image imageitem = new Image();
BitmapImage image = new BitmapImage(new System.Uri(selecteditem.Imageurl, UriKind.Absolute));
imageitem.Source = image;
my_canvas.Children.Add(imageitem);
imageitem.AllowDrop = true;
imageitem.ManipulationMode = ManipulationModes.All;
imageitem.ManipulationDelta += Drag_ManipulationDelta;
dragTranslation = new TranslateTransform();
imageitem.RenderTransform = this.dragTranslation;
var st = (ScaleTransform)imageitem.RenderTransform;
double zoom = e.Delta > 0 ? .2 : -.2;
st.ScaleX += zoom;
st.ScaleY += zoom;

}
my_canvas.Visibility = Visibility.Visible;
}
Posted
Updated 10-Jun-16 8:15am

1 solution

A great Article about Zoom/Pan/Move Images exists here on CP:

A WPF Custom Control for Zooming and Panning[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900