1

Hi I have a style that animates a border and its content when it is set to visible. The EnterACtion work great but the ExitAction is not working when the content control is set to Hidden or Collapsed.

Style :

<Style x:Key="BorderTransition" TargetType="{x:Type ContentControl}">
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="BorderBrush" Value="{StaticResource AccentBrush}"></Setter>
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="ContentControl">
            <Border x:Name="container" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Opacity="0">
                <ContentPresenter 
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    RecognizesAccessKey="True"/>
            </Border>                   
            <ControlTemplate.Triggers>
                <Trigger Property="IsVisible" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation 
                                    Storyboard.TargetName="container" 
                                    Storyboard.TargetProperty="Opacity" 
                                    From="0.0" 
                                    To="1.0" 
                                    Duration="00:00:02" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="container" Storyboard.TargetProperty="Opacity" Duration="0:0:10">
                                    <LinearDoubleKeyFrame Value="1" KeyTime="0:0:0" />
                                    <LinearDoubleKeyFrame Value="1" KeyTime="0:0:9" />
                                    <LinearDoubleKeyFrame Value="0" KeyTime="0:0:10" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.ExitActions>
                </Trigger>

            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Setter.Value>
</Setter>

Regards,

theHaggis
  • 615
  • 7
  • 18
  • 1
    I might not be familiar with the topic, but this is border-line not enough information. Simply saying "it doesn't work" is not very helpful. Also, please don't use signatures in your post. SO [is not like other forums](http://stackoverflow.com/faq#signatures). – gunr2171 May 29 '13 at 15:48
  • When the control Visibility property is set to Hidden or Collapsed i want the ExitAction to be performed. It isn't. it is simply disappearing. – theHaggis May 29 '13 at 16:02
  • Try adding `From=1.0` and `To=0.0` and see if that works. – Arian Motamedi May 29 '13 at 16:06
  • 1
    @programmer93 This will not work because you can't see an animation of a collapsed or hidden control. – LPL May 29 '13 at 16:09
  • @LPL that explains it cheers. – theHaggis May 29 '13 at 16:12

0 Answers0