When I write down the following: when I click on the button with the left mouse button, the Activate command will work. How can I make it so that when you press the RMB to this button, another command will work, say onRightClickActivate?

    1 answer 1

    Add the System.Windows.Interactivity assembly and declare the namespace:

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 

    After that, we can assign a command to the desired event as follows:

     <Button> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseRightButtonDown"> <i:InvokeCommandAction Command="{Binding Path=DoSomethingCommand}"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> 

    A source.

    • The name "Interaction" does not exist in the namespace " schemas.microsoft.com/expression/2010/interactivity ". - Draktharon
    • @Draktharon, The assembly itself was added? - trydex
    • No, that was the problem and it was solved, thanks - Draktharon
    • @Draktharon, please. Glad to help! - trydex