WPF Trigger animation when Visibility is changed?

10,030

I tried this too and failed. I think it is not possible to accomplish this in a simple ControlTemplate with a Trigger on the Visibility property. What you can do is add an Opacity animation From 1 To 0 to a Trigger for a different property, for instance a DependencyProperty that you add in the code behind yourself.

Share:
10,030
Raven
Author by

Raven

https://github.com/AnderssonPeter

Updated on June 04, 2022

Comments

  • Raven
    Raven almost 2 years

    Well i have a custom control and when Visibility is changed to Visible I have a Trigger with a enter/exit action but the problem is that when the exit action fires the Visibility is no longer Visible so the animation can't be seen how would I fix this?

    here is my Trigger:

    <ControlTemplate.Triggers>
        <Trigger Property="Visibility" Value="Visible">
            <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource Hide}"/>
            </Trigger.ExitActions>
            <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource Show}"/>
            </Trigger.EnterActions>
        </Trigger>
    </ControlTemplate.Triggers>