WPF "button" that allows MouseLeftButtonDown and MouseLeftButtonUp events to fire

189 Views Asked by At

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>
0

There are 0 best solutions below