On the View
there are several Image
they can be resized to move and rotate. Here is the Xaml
View
code:
<Image Width="525" Height="331" Canvas.Top="-199" Canvas.Left="-361" x:Name="CollageImg1" ManipulationMode="All" Source="{Binding CollageImg1}" RenderTransformOrigin="0.5,0.5" ManipulationDelta="CollageImgage1_Manipulation">// <Image.RenderTransform> <CompositeTransform></CompositeTransform> </Image.RenderTransform> </Image>
The codecode method for interaction
private void OnDrag(object sender, ManipulationDeltaRoutedEventArgs e) { ImageManipulator.Manipulation(e, CollageImg1); }
Which calls a common method for interacting with pictures.
public static void Manipulation(ManipulationDeltaRoutedEventArgs e, Image xamlimage) { CompositeTransform ct = (CompositeTransform)xamlimage.RenderTransform; ct.ScaleX *= e.Delta.Scale; ct.ScaleY *= e.Delta.Scale; ct.TranslateX += e.Delta.Translation.X; ct.TranslateY += e.Delta.Translation.Y; ct.Rotation += Math.PI * e.Delta.Rotation; }
The question is how can this be taken out of the codebeehind? Command
does not work for Image
. What should I use?
public ICommand ManipulationCommand => _manipulateCommand ?? (_manipulateCommand = new CommandHandler(() => OnDrag(), _canExecuteManipulate));