如何使WPF文本块在其值更新时旋转?
无论何时绑定更新,我都会尝试将文本块旋转360度 从我所读到的一切来看,以下内容应该是有效的,但是它没有任何效果。我做错了什么如何使WPF文本块在其值更新时旋转?,wpf,binding,rotation,routed-events,Wpf,Binding,Rotation,Routed Events,无论何时绑定更新,我都会尝试将文本块旋转360度 从我所读到的一切来看,以下内容应该是有效的,但是它没有任何效果。我做错了什么 <TextBlock VerticalAlignment="Center" Text="{Binding Total, NotifyOnTargetUpdated=True}"> <TextBlock.RenderTransform> <RotateTransform x:Name="TotalSpinTransf
<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>
Enteraction和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>
Enteraction和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>
运行时在输出窗口中看到警告了吗?运行时在输出窗口中看到警告了吗?哈。。。我甚至都没注意到这是一个行动。。。我只是假设了我在解决方案中所采取的行动,并通过将其放在样式中模拟了一个示例。好主意!哈我甚至都没注意到这是一个行动。。。我只是假设了我在解决方案中所采取的行动,并通过将其放在样式中模拟了一个示例。好主意!