wpf,前端动画demo,鱼眼效果
如题,鱼眼。特此备注下
1 <Window x:Class="WpfApp2.Window3" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:local="clr-namespace:WpfApp2" 7 mc:Ignorable="d" 8 Title="Window3" Height="370" Width="370"> 9 <Window.Resources> 10 <Style TargetType="ListBoxItem"> 11 <Setter Property="Foreground"> 12 <Setter.Value> 13 <SolidColorBrush Color="Black" /> 14 </Setter.Value> 15 </Setter> 16 <Setter Property="FontSize" Value="25" /> 17 <Setter Property="HorizontalAlignment" Value="Center" /> 18 <Style.Triggers> 19 <EventTrigger RoutedEvent="ListBoxItem.MouseEnter"> 20 <EventTrigger.Actions> 21 <BeginStoryboard Name="aa"> 22 <Storyboard> 23 <ColorAnimation From="Black" 24 To="Red" 25 Duration="0:0:0.3" 26 Storyboard.TargetProperty="(ListBoxItem.Foreground).(SolidColorBrush.Color)" /> 27 <DoubleAnimation To="40" 28 Duration="0:0:0.25" 29 Storyboard.TargetProperty="FontSize" /> 30 </Storyboard> 31 </BeginStoryboard> 32 </EventTrigger.Actions> 33 </EventTrigger> 34 <EventTrigger RoutedEvent="ListBoxItem.MouseLeave"> 35 <EventTrigger.Actions> 36 <!--<StopStoryboard BeginStoryboardName="aa"/>--> 37 <BeginStoryboard Name="aa1"> 38 <Storyboard> 39 <ColorAnimation From="Red" 40 To="Black" 41 Duration="0:0:0.25" 42 Storyboard.TargetProperty="(ListBoxItem.Foreground).(SolidColorBrush.Color)" /> 43 <DoubleAnimation To="25" 44 Duration="0:0:0.2" 45 Storyboard.TargetProperty="FontSize" /> 46 </Storyboard> 47 </BeginStoryboard> 48 </EventTrigger.Actions> 49 </EventTrigger> 50 51 <!--绑定外部值 如下:--> 52 <!--<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:Window3},Path=IsSelected}" Value="true"> 53 <DataTrigger.EnterActions> 54 <BeginStoryboard Name="bb"> 55 <Storyboard> 56 <ColorAnimation From="Green" 57 To="Yellow" 58 RepeatBehavior="Forever" 59 Duration="0:0:0.5" 60 Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" /> 61 </Storyboard> 62 </BeginStoryboard> 63 </DataTrigger.EnterActions> 64 </DataTrigger> 65 <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:Window3},Path=IsSelected}" Value="false"> 66 <DataTrigger.EnterActions> 67 <StopStoryboard BeginStoryboardName="bb" /> 68 </DataTrigger.EnterActions> 69 </DataTrigger>--> 70 </Style.Triggers> 71 </Style> 72 </Window.Resources> 73 <Grid> 74 <ListBox> 75 <ListBoxItem Content="001_我" /> 76 <ListBoxItem Content="002_是" /> 77 <ListBoxItem Content="003_鱼" /> 78 <ListBoxItem Content="004_眼" /> 79 <ListBoxItem Content="005_效" /> 80 <ListBoxItem Content="006_果" /> 81 <ListBoxItem Content="007_。" /> 82 <ListBoxItem Content="008_酷~" /> 83 </ListBox> 84 </Grid> 85 </Window>