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)); 

    2 answers 2

    Behaviors can be used.

     <i:Interaction.Behaviors> <core:EventTriggerBehavior EventName="Tapped"> <core:InvokeCommandAction Command="{Binding Любая_команда}"/> </core:EventTriggerBehavior> </i:Interaction.Behaviors> 
    • And what do I need to pass in the parameters to my method? And in Xaml you need to specify the parameters or only in the class? - SmiLe
    • <core:InvokeCommandAction Command="{Binding Любая_команда}" CommandParameter="то_что_хотите_передать_в_метод. "/> If you don’t transfer anything, the standard EventArgs event is transmitted - Make Makeluv
    • And, by the way, instead of Tapped substitute the desired event, which should trigger the command. - Make Makeluv
    • I meant here how to convey? joxi.ru/Dr83OBecl5DOA6 - SmiLe
    • Through typed commands. In a prism it looks like this: DelegateCommand<object>((obj) => { код }); Make in the image and likeness. See what comes in the object and redo it for you. - Make Makeluv
    1. Add xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

    2. Use EventTrigger :

        <Image Width="525" Height="331" Canvas.Top="-199" Canvas.Left="-361" x:Name="CollageImg1" ManipulationMode="All" Source="{Binding CollageImg1}" RenderTransformOrigin="0.5,0.5" <Image.RenderTransform> <CompositeTransform></CompositeTransform> </Image.RenderTransform> <i:Interaction.Triggers> <i:EventTrigger EventName="ManipulationDelta"> <i:InvokeCommandAction Command="{Binding }"/> </i:EventTrigger> </i:Interaction.Triggers> </Image> 
    • Using registered, but after i everything is red and offers to connect Microsoft's Behavior - SmiLe
    • It needs to be added to the xaml at the very top - Gardes
    • Yes, the line is even highlighted what is being used. But joxi.ru/V2V5g9kIWJ4Rmv - SmiLe
    • In this case, do not need to add anything) the code works? Binding passes? - Gardes
    • No, then he doesn’t see Triggers , EventName and InvokeCommandAction - SmiLe