Reputation: 55
have discovered that the Mouse up work properly most of the time, they just do not get fired when my mouse has begun moving after the initial click. I have a pretty heavy mouse move event. So the only conclusion i can draw is that the mouse move event is some how preventing the mouse button up event from firing. Any thoughts please.
Note: I am using MVVM model.
<Grid >
<Image x:Name="DynamicJoystickWindow" RenderTransformOrigin="0.5,0.5">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseUp" >
<cmd:EventToCommand Command="{Binding JoystickMouseUp_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<!--<i:EventTrigger EventName="MouseUp" >
<cmd:EventToCommand Command="{Binding JoystickMouseUp_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>-->
<i:EventTrigger EventName="PreviewMouseDown">
<cmd:EventToCommand Command="{Binding JoystickMouseDown_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove" >
<cmd:EventToCommand Command="{Binding JoystickMouseMove_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<!--<i:EventTrigger EventName="MouseMove" >
<cmd:EventToCommand Command="{Binding JoystickMouseMove_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>-->
</i:Interaction.Triggers>
<Image.RenderTransform>
<ScaleTransform ScaleX="{Binding RenderScaleTransform}" ScaleY="{Binding RenderScaleTransform}"/>
</Image.RenderTransform>
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="Resources/transparent.png"/>
<Setter Property="Opacity" Value="0.3" />
</Style>
</Image.Style>
</Image>
</Grid>
Upvotes: 0
Views: 1879
Reputation: 55
Thanks guys. Problem is, I had the image size smaller than the grid. as @Ouarzy suggested, had grid only and tried. the mouse events works as expected.
Upvotes: 0
Reputation: 3043
I do not observe the behavior you describe, so I would suggest you to simplify your problem to understand what's going on.
For example, remove your image and work only with the grid to see if something change.
I used the following code and it works well for me:
<Grid x:Name="DynamicJoystickWindow" RenderTransformOrigin="0.5,0.5" Background="Blue">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseUp" >
<command:EventToCommand Command="{Binding JoystickMouseUp_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseDown">
<command:EventToCommand Command="{Binding JoystickMouseDown_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove" >
<command:EventToCommand Command="{Binding JoystickMouseMove_Dynamic}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Grid>
The only case where event is not fired is when I finish my move outside of the grid.
Hope it helps.
Upvotes: 1