Get notified when the left mouse button is released?

Gauge for WPF Forum

Posted 9 years ago by Julien Poulin
Version: 9.2.0515
Avatar
Hello,

I CircularGauge in interactive mode (CanDrag of the needle = true) and I'm trying to get a notification when the left mouse button is released. I've tried the MouseUp and MouseLeftButtonUp events on the Gauge control as well as the MouseUp and MouseLeftButtonUp events on the Needle control. Here is the Xaml I'm using (I've removed the non working event hook ups):

<Gauge:CircularGauge BackgroundType="None" RimType="None" Width="196" Height="171">
  <ACB:CommandBehaviorCollection.Behaviors>
      <ACB:BehaviorBinding Event="MouseLeave" Command="{Binding ReleaseOutsideServiceKeySwitchCommand}" />
          <!-- The line below doesn't work -->
      <ACB:BehaviorBinding Event="MouseLeftButtonUp" Command="{Binding ReleaseOutsideServiceKeySwitchCommand}" />
  </ACB:CommandBehaviorCollection.Behaviors>
    <Gauge:CircularScale StartAngle="225" SweepAngle="90" IsBarVisible="False">
        <Gauge:CircularTickSet Minimum="0" Maximum="2" MajorInterval="1" MinorInterval="1">
            <Gauge:CircularTickSet.Ticks>
                <Gauge:CircularTickLabelCustom Value="0" Text="C.L." FontSize="18" />
                <Gauge:CircularTickLabelCustom Value="1" Text="0" FontSize="18" ScaleOffset="10" ScalePlacement="Inside" />
                <Gauge:CircularTickLabelCustom Value="2" Text="S.O." FontSize="18" />
            </Gauge:CircularTickSet.Ticks>
            <Gauge:CircularTickSet.Pointers>
                <Gauge:CircularPointerNeedle Value="{Binding ServiceKeySwitch, Mode=TwoWay, FallbackValue=1}" ImageSource="/VirtualTrain;Component/Images/Selector.png" NeedleType="CustomImage" CanDrag="True" IsSnappingEnabled="True" HasDropShadow="False" />
            </Gauge:CircularTickSet.Pointers>
        </Gauge:CircularTickSet>
    </Gauge:CircularScale>
</Gauge:CircularGauge>
Please also note that I was able to bind to the MouseLeave event without any difficulty.

Is there a way I can get notified when the left mouse button is released?

Thank you in advance.

[Modified at 03/23/2010 11:52 AM]

Comments (2)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Julien,

The pointers will set e.Handled to true, so you would have to add a handler for "handled" events. Check out UIElement.AddHandler(RoutedEvent routedEvent, Delegate handler, bool handledEventsToo).

If you can't add a handler that way, you could create a class that derives from CircularPointerNeedle and override OnMouseLeftButtonUp. In your override, you'd call the base class, then reset e.Handled to false.


Actipro Software Support

Posted 9 years ago by Julien Poulin
Avatar
Thank you, it works great.
The latest build of this product (v2018.1 build 0675) was released 14 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.