IsVisible上的触发器ExitAction等于true

时间:2013-05-29 15:45:30

标签: c# .net wpf xaml

嗨我有一个样式,当设置为可见时,动画边框及其内容。 EnterACtion工作正常,但当内容控件设置为隐藏或折叠时,ExitAction不起作用。

风格:

<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>

此致

0 个答案:

没有答案