码迷,mamicode.com
首页 > Windows程序 > 详细

WPF 精修篇 属性动画

时间:2019-12-21 00:35:55      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:登录   技术   span   mouse   out   use   boa   通过   string   

原文:WPF 精修篇 属性动画

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

技术图片

 

  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 精修篇 属性动画

标签:登录   技术   span   mouse   out   use   boa   通过   string   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12075531.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!