WPF 精修篇 属性动画

原文:WPF 精修篇 属性动画

属性动画 是通过 Storyboard 来改变属性值

WPF 精修篇 属性动画

 

  1. <Rectangle x:Name="rect" Width="200" Height="200" >
  2. <Rectangle.Fill>
  3. <SolidColorBrush Color="Beige" x:Name="color"></SolidColorBrush>
  4. </Rectangle.Fill>
  5. <Rectangle.Triggers>
  6. <EventTrigger RoutedEvent="MouseEnter">
  7. <EventTrigger.Actions>
  8. <BeginStoryboard>
  9. <Storyboard>
  10. <DoubleAnimation Duration="0:0:1" Storyboard.TargetName="rect" Storyboard.TargetProperty="Width" To="400"></DoubleAnimation>
  11. <ColorAnimation Duration="0:0:1" Storyboard.TargetName="color" Storyboard.TargetProperty="Color" To="Cyan"></ColorAnimation>
  12. <DoubleAnimation Duration="0:0:1" Storyboard.TargetName="rect" Storyboard.TargetProperty="Height" To="400"></DoubleAnimation>
  13. </Storyboard>
  14. </BeginStoryboard>
  15. </EventTrigger.Actions>
  16. </EventTrigger>
  17. <EventTrigger RoutedEvent="MouseLeave">
  18. <EventTrigger.Actions>
  19. <BeginStoryboard>
  20. <Storyboard>
  21. <DoubleAnimation Duration="0:0:1" Storyboard.TargetName="rect" Storyboard.TargetProperty="Width" To="200"></DoubleAnimation>
  22. <ColorAnimation Duration="0:0:1" Storyboard.TargetName="color" Storyboard.TargetProperty="Color" To="Beige"></ColorAnimation>
  23. <DoubleAnimation Duration="0:0:1" Storyboard.TargetName="rect" Storyboard.TargetProperty="Height" To="200"></DoubleAnimation>
  24. </Storyboard>
  25. </BeginStoryboard>
  26. </EventTrigger.Actions>
  27. </EventTrigger>
  28. </Rectangle.Triggers>
  29. </Rectangle>

 

WPF 精修篇 属性动画

上一篇:WPF 精修篇 属性触发器


下一篇:对百度WebUploader开源上传控件的二次封装,精简前端代码(两句代码搞定上传)