事件触发器 一般使用的就是动画
- <Grid>
- <TextBlock Text="事件触发器" Opacity="0.2" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center">
- <TextBlock.Style>
- <Style TargetType="{x:Type TextBlock}">
- <Style.Triggers>
- <EventTrigger RoutedEvent="MouseEnter">
- <EventTrigger.Actions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" To="1"></DoubleAnimation>
- <DoubleAnimation Storyboard.TargetProperty="FontSize" Duration="0:0:0.5" To="50"></DoubleAnimation>
- </Storyboard>
- </BeginStoryboard>
- </EventTrigger.Actions>
- </EventTrigger>
- <EventTrigger RoutedEvent="MouseLeave">
- <EventTrigger.Actions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" To="0.2"></DoubleAnimation>
- <DoubleAnimation Storyboard.TargetProperty="FontSize" Duration="0:0:0.5" To="30"></DoubleAnimation>
- </Storyboard>
- </BeginStoryboard>
- </EventTrigger.Actions>
- </EventTrigger>
- </Style.Triggers>
- </Style>
- </TextBlock.Style>
- </TextBlock>
- </Grid>
动手写 比较精简 用Blend 来写 会生成很多代码哟
原文地址:https://www.cnblogs.com/lonelyxmas/p/12075489.html
时间: 2024-11-05 18:52:14