1

每当绑定更新时,我都会尝试将 TextBlock 旋转 360 度。

从我读过的所有内容来看,以下内容应该可以工作,但是它没有任何效果。我究竟做错了什么?

<TextBlock VerticalAlignment="Center" Text="{Binding Total, NotifyOnTargetUpdated=True}">

    <TextBlock.RenderTransform>
        <RotateTransform x:Name="TotalSpinTransform" Angle="0"/>
    </TextBlock.RenderTransform>

    <TextBlock.Triggers>
        <EventTrigger RoutedEvent="Binding.TargetUpdated">
            <EventTrigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetProperty="(TextBlock.RenderTransform).(RotateTransform.Angle)" 
                            From="0" To="360" Duration="0:0:0.2" AutoReverse="True"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.EnterActions>
        </EventTrigger>
    </TextBlock.Triggers>

</TextBlock>       
4

1 回答 1

4

既不EnterActions也不ExitActions适用于EventTrigger。不幸的是,这些属性是在 上定义的,TriggerBase因此它们存在于EventTrigger. 试试这个:

    <EventTrigger RoutedEvent="Binding.TargetUpdated">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetProperty="(TextBlock.RenderTransform).(RotateTransform.Angle)" 
                        From="0" To="360" Duration="0:0:0.2" AutoReverse="True"/>
                </Storyboard>
            </BeginStoryboard>
    </EventTrigger>
于 2011-03-04T20:02:09.840 回答