user3821206
user3821206

Reputation: 619

disable the animation on the button when hover on it in a universal app

I have defined this Style for my button in a universal App like this,I tried to remove the minimization of the button size when I hover on it:

enter image description here

but I have failed,I tried also to remove the PointerOver Block but that affects the Color inversion Style that I have defined to the button :(

<VisualState x:Name="PointerOver"></VisualState>

this is my Style:

 <Style TargetType="Button" x:Key="btnForgroundColorWhenHoverWhite">
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal">
                                <Storyboard>
                                    <PointerUpThemeAnimation Storyboard.TargetName="RootGrid" />
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="PointerOver">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
                                               Storyboard.TargetProperty="Background">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="White" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                               Storyboard.TargetProperty="BorderBrush">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                               Storyboard.TargetProperty="Foreground">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="#1d84eb" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <PointerDownThemeAnimation Storyboard.TargetName="RootGrid" />
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <ContentPresenter x:Name="ContentPresenter"
                      BorderBrush="Transparent"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      Content="{TemplateBinding Content}"
                      ContentTransitions="{TemplateBinding ContentTransitions}"
                      ContentTemplate="{TemplateBinding ContentTemplate}"
                      Padding="{TemplateBinding Padding}"
                      HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                      AutomationProperties.AccessibilityView="Raw"
                                      Foreground="White"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

so please,is it possible to disable the animation on the button when I hover on it

thanks for help

Upvotes: 0

Views: 517

Answers (1)

Vincent
Vincent

Reputation: 3746

You just have to remove the PointerDownThemeAnimation from the storyboard. This is the one controlling the minimization effect.

<PointerDownThemeAnimation Storyboard.TargetName="RootGrid" />

If you want to completely remove the PointerOver animations, you can remove the content of the PointerOver visual state

<VisualState x:Name="PointerOver">
    <Storyboard>

    </Storyboard>
</VisualState>

Upvotes: 1

Related Questions