Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
I want to resize and move a image control using the mouse drag option in WPF. If you knows please help me.
Posted
Comments
Sergey Alexandrovich Kryukov 22-Oct-12 13:36pm    
What did you try? This is simple enough.
--SA
ssyuvaraja 30-Oct-12 5:34am    
Do you know how to make a video to move one frame forward and one frame backward in media element in WPF. If you know please help me on it.
Sergey Alexandrovich Kryukov 30-Oct-12 10:11am    
This is unrelated question. No, I did not ever try to address such problem, not sure media element is designed to do such things; cannot tell you anything more certain, sorry.
--SA
ssyuvaraja 2-Nov-12 0:03am    
Ok And Thank you.

1 solution

This is simple enough. For a image control's parent, use the instance of the class System.Windows.Controls.Canvas. Handle the events MouseDown, MouseUp and MouseMove of the instance of your moving control. For modification of location, use the modification of an attached property of the instance of the canvas for your moving object. This is as simple as using the methods Canvas.SetLeft(UIElement element, double length), Canvas.SetTop(UIElement element, double length) and the like, where element is your control you want to move:
http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx[^].

Everything else is just pure logic of your code.

See also this overview on attached properties, to understand how it works:
http://msdn.microsoft.com/en-us/library/ms749011.aspx[^].

—SA
 
Share this answer
 
Comments
ssyuvaraja 25-Oct-12 2:47am    
Thank you. I am now only learning WPF.
Sergey Alexandrovich Kryukov 25-Oct-12 12:58pm    
You are very welcome.
Good luck, call again.
--SA

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