在WPF中触发器上的不同控件上启动故事板

时间:2011-06-03 01:37:05

标签: wpf animation storyboard

如果在ellipse1上运行一个故事板动画来改变不透明度,我可以在其不透明度上触发某个值并在ellipse2上启动一个故事板动画,它将开始淡入吗?

<UniformGrid Columns="2">
    <Ellipse Width="25" Height="25" Name="ellipse1">
        <Ellipse.Triggers>
            <Trigger Property="Opacity" Value=".7">
                do something here to start a opacity fade in on ellipse2
            </Trigger>
        </Ellipse.Triggers>
    </Ellipse>
    <Ellipse Width="25" Height="25" Name="ellipse2">

    </Ellipse>
</UniformGrid>

1 个答案:

答案 0 :(得分:2)

您可以在ellipse2中使用DataTrigger来观察ellipse1:

<Ellipse Width="25" Height="25" Name="ellipse2">
    <Ellipse.Style>
        <Style TargetType="{x:Type Ellipse}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Opacity, ElementName=ellipse1}" Value="0.5">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard>
                            <!-- Storyboard for ellipse 2 here -->
                        </BeginStoryboard>
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Ellipse.Style>
</Ellipse>