Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable default animation on WPF Button

Tags:

c#

wpf

In WPF: how to disable the animation when the button after be pressed?

This thing above solves the problem, but it changes whole template, is there any more elegant solution, for example something like this:

<Style.Triggers>
    <Trigger Property="IsFocused" Value="True">
        <Setter Property="StoryBoard" Value="Disable" />
    </Trigger>
    <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="StoryBoard" Value="Disable" />
    </Trigger>
</Style.Triggers>
like image 548
jovanMeshkov Avatar asked Mar 22 '23 21:03

jovanMeshkov


1 Answers

you can also use a handler for PreviewMouseLeftButtonDown instead ButtonClick

function will be the same and command e.Handled = true; ensures that the animation does not start

 private void button_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

            //some your code
            e.Handled = true;
        }
like image 159
Luděk Urbanič Avatar answered Apr 02 '23 02:04

Luděk Urbanič