1

我想在控件的 Loaded 事件上执行许多动画:

 <EventTrigger RoutedEvent="Button.Loaded">
     <BeginStoryboard>
         <Storyboard>                                
             <DoubleAnimation ...
             <DoubleAnimation ...
             <DoubleAnimation ...

我想做的是并行执行前两个(这似乎是默认行为),最后一个在它们完成后执行。这可能吗?如果可以,怎么做?

4

1 回答 1

1

Blend“交互性”DLL 支持这种情况。在第一个故事板上设置StoryboardCompletedTrigger ,在第二个故事板上设置ControlStoryboardAction。例如(请注意,这需要引用 System.Windows.Interactivity.dll 和 Microsoft.Expression.Interactions.dll):

<Grid x:Name="LayoutRoot"
     xmlns:em="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
>
    <Grid.Resources>
        <Storyboard x:Name="FirstStoryboard">
            <DoubleAnimation ...
            <DoubleAnimation ...
        </Storyboard>

        <Storyboard x:Name="SecondStoryboard">
            <DoubleAnimation ...
        </Storyboard>
    </Grid.Resources>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <em:ControlStoryboardAction Storyboard="{StaticResource FirstStoryboard}" />
        </i:EventTrigger>

        <em:StoryboardCompletedTrigger Storyboard="{StaticResource FirstStoryboard}">
            <em:ControlStoryboardAction Storyboard="{StaticResource SecondStoryboard}" />
        </em:StoryboardCompletedTrigger>
    </i:Interaction.Triggers>
</Grid>
于 2013-10-17T16:57:37.840 回答