WPF 精修篇 事件触发器

原文:WPF 精修篇 事件触发器

事件触发器 一般使用的就是动画

WPF 精修篇 事件触发器

  1. <Grid>
  2. <TextBlock Text="事件触发器" Opacity="0.2" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center">
  3. <TextBlock.Style>
  4. <Style TargetType="{x:Type TextBlock}">
  5. <Style.Triggers>
  6. <EventTrigger RoutedEvent="MouseEnter">
  7. <EventTrigger.Actions>
  8. <BeginStoryboard>
  9. <Storyboard>
  10. <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" To="1"></DoubleAnimation>
  11. <DoubleAnimation Storyboard.TargetProperty="FontSize" Duration="0:0:0.5" To="50"></DoubleAnimation>
  12. </Storyboard>
  13. </BeginStoryboard>
  14. </EventTrigger.Actions>
  15. </EventTrigger>
  16. <EventTrigger RoutedEvent="MouseLeave">
  17. <EventTrigger.Actions>
  18. <BeginStoryboard>
  19. <Storyboard>
  20. <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" To="0.2"></DoubleAnimation>
  21. <DoubleAnimation Storyboard.TargetProperty="FontSize" Duration="0:0:0.5" To="30"></DoubleAnimation>
  22. </Storyboard>
  23. </BeginStoryboard>
  24. </EventTrigger.Actions>
  25. </EventTrigger>
  26. </Style.Triggers>
  27. </Style>
  28. </TextBlock.Style>
  29. </TextBlock>
  30. </Grid>

动手写 比较精简 用Blend 来写 会生成很多代码哟

 

WPF 精修篇 事件触发器

上一篇:postgresql python 批量插入


下一篇:mysql 多版本共存(windows)