0

I'm trying to figure out a way to simply have a user control that has the same functionalities of a "button" but doesn't prevent the "MouseLeftButtonDown" and "MouseLeftButtonUp" to bubble up.

For my specific application, I cannot solve it with any code behind tricks - I'm bound to the MVVM pattern to forward the command to other processes.

I found many discussions about the topic but none that pointed to a simple solution.

To be clear a non-working example:

<Button Width="30" Height="20" Content="+">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseLeftButtonDown">
            <i:InvokeCommandAction Command="{Binding MoveAxisFwdCommand}" CommandParameter="true" />
        </i:EventTrigger>
            <i:EventTrigger EventName="MouseLeftButtonUp">
                <i:InvokeCommandAction Command="{Binding MoveAxisFwdCommand}" CommandParameter="false" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Button>
piter123
  • 61
  • 1
  • 3
  • 1
    Have you tried the `Preview...` events? i.e. `PreviewMouseLeftButtonDown` – the.Doc Nov 30 '21 at 10:51
  • Yes, that worked! I could swear I tried it already (and without success), but I must have messed up something else before.. Thanks. – piter123 Nov 30 '21 at 11:59

0 Answers0