WPF中连续旋转时角度错误的问题<Window x:Class="ImageZoomTest.Window1"
WPF中连续旋转时角度错误的问题xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowState="Maximized">
WPF中连续旋转时角度错误的问题  
<Grid Margin="0" Name="gridMain">
WPF中连续旋转时角度错误的问题    
<Grid.ColumnDefinitions>
WPF中连续旋转时角度错误的问题      
<ColumnDefinition Width="0.7*"/>
WPF中连续旋转时角度错误的问题      
<ColumnDefinition Width="0.3*"/>
WPF中连续旋转时角度错误的问题    
</Grid.ColumnDefinitions>
WPF中连续旋转时角度错误的问题    
<DockPanel Grid.Column="0">
WPF中连续旋转时角度错误的问题      
<Image Name="imageLarge" Source="Image\1600XMAS_3001.jpg" Width="800" Height="500">
WPF中连续旋转时角度错误的问题          
<Image.RenderTransform>
WPF中连续旋转时角度错误的问题            
<RotateTransform x:Name="imageLargeRotateTransform" Angle="0"/>
WPF中连续旋转时角度错误的问题          
</Image.RenderTransform>
WPF中连续旋转时角度错误的问题        
</Image>
WPF中连续旋转时角度错误的问题    
</DockPanel>
WPF中连续旋转时角度错误的问题    
<DockPanel Grid.Column="1">
WPF中连续旋转时角度错误的问题      
<Button Name="btnRotateClockwise" Content="Rotate clockWise" DockPanel.Dock="Bottom" >
WPF中连续旋转时角度错误的问题        
<Button.Triggers>
WPF中连续旋转时角度错误的问题          
<EventTrigger RoutedEvent="Button.Click">
WPF中连续旋转时角度错误的问题            
<BeginStoryboard>
WPF中连续旋转时角度错误的问题              
<Storyboard>
WPF中连续旋转时角度错误的问题                
<DoubleAnimation Storyboard.TargetName="imageLargeRotateTransform" Storyboard.TargetProperty="Angle" By="90" Duration="0:0:1" />
WPF中连续旋转时角度错误的问题              
</Storyboard>
WPF中连续旋转时角度错误的问题            
</BeginStoryboard>
WPF中连续旋转时角度错误的问题          
</EventTrigger>
WPF中连续旋转时角度错误的问题        
</Button.Triggers>
WPF中连续旋转时角度错误的问题      
</Button>
WPF中连续旋转时角度错误的问题    
</DockPanel>
WPF中连续旋转时角度错误的问题  
</Grid>
WPF中连续旋转时角度错误的问题
</Window>
上面这段代码的效果是点击一下button,图片顺时针旋转90度,动画时间是1秒针。如果点击按钮时候比较慢,两次点击的间隔大于1秒,运行正常。但是如果点击的很快,第一次点击的动画还没有结束,第二次点击的动画又开始了,图片最后停止时停留的角度就有问题了。

解决这种现象的方法很简单,只要在BeginStoryboard里面设置HandoffBehavior属性为Compose就可以了: <BeginStoryboard HandoffBehavior ="Compose" >。
WPF中连续旋转时角度错误的问题

相关文章:

  • 2021-05-22
  • 2021-10-03
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-01-09
  • 2021-11-23
猜你喜欢
  • 2021-04-14
  • 2021-05-30
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案