Answer the question
In order to leave comments, you need to log in
WPF. XAML. The MouseUp event for LMB does not work. How to fix?
There is a style for the button. The button itself is two rectangles (on one background color, on the other image with transparency).
<Rectangle Name="RectangleBackground"
HorizontalAlignment="Stretch"
Fill="#D01600"
Opacity="0"/>
<Rectangle Name="Rectangle"
HorizontalAlignment="Stretch"
Margin="5"
Fill="{TemplateBinding Control.Background}"
Opacity="1"/>
<EventTrigger RoutedEvent="MouseDown" SourceName="Rectangle">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="RectangleBackground"
Storyboard.TargetProperty="Opacity"
From="1" To="0.5" Duration="0:0:0.15"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
Answer the question
In order to leave comments, you need to log in
As I was told, the problem is in SourceName if used with PreviewMouseUp or PreviewMouseLeftButtonUp. Works without it:
<EventTrigger RoutedEvent="PreviewMouseUp">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="RectangleBackground"
Storyboard.TargetProperty="Opacity"
From="1" To="0.5" Duration="0:0:0.15"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question