0

MyObject.IsGlowing = true我希望在我这样做时启动动画(<DataTemplate>如果有帮助的话,我很乐意)

<Ellipse Width="100" Height="100" Name="MyEllipse">
    <Ellipse.Fill>
        <RadialGradientBrush >
            <GradientStop Offset="0" Color="Red" />
            <GradientStop Offset="0.5" Color="red" />
            <GradientStop Offset="1" Color="red"/>
        </RadialGradientBrush >
    </Ellipse.Fill>
    <Ellipse.Triggers>
        <DataTrigger Binding="{Binding Source=IsGlowing}" Value="True">
            <DataTrigger.EnterActions>
                <BeginStoryboard Name="MyBeginStoryBoard">
                    <Storyboard Name="MyStoryBoard" >
                        //Animation
                    </Storyboard>
                </BeginStoryboard>
            </DataTrigger.EnterActions>
        </DataTrigger>
    </Ellipse.Triggers>
</Ellipse>

但我收到此错误“触发器集合成员必须是 EventTrigger 类型”所以我将其更改为

<Ellipse Width="100" Height="100" Name="MyEllipse">
    <Ellipse.Fill>
        <RadialGradientBrush >
            <GradientStop Offset="0" Color="Red" />
            <GradientStop Offset="0.5" Color="red" />
            <GradientStop Offset="1" Color="red"/>
        </RadialGradientBrush >
    </Ellipse.Fill>
    <Ellipse.Triggers>
        <EventTrigger RoutedEvent="?">
                <BeginStoryboard Name="MyBeginStoryBoard">
                    <Storyboard Name="MyStoryBoard" >
                        //Animation
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
    </Ellipse.Triggers>
</Ellipse>

但我不知道在RoutedEvent中放什么......

4

1 回答 1

1

不允许在元素触发器集合中直接使用/指定 DataTriggers。但是,您可以使用样式来应用样式。

于 2012-08-22T16:29:55.050 回答