如题,鱼眼。特此备注下
<Window x:Class="WpfApp2.Window3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="Window3" Height="370" Width="370">
<Window.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="Black" />
</Setter.Value>
</Setter>
<Setter Property="FontSize" Value="25" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Style.Triggers>
<EventTrigger RoutedEvent="ListBoxItem.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard Name="aa">
<Storyboard>
<ColorAnimation From="Black"
To="Red"
Duration="0:0:0.3"
Storyboard.TargetProperty="(ListBoxItem.Foreground).(SolidColorBrush.Color)" />
<DoubleAnimation To="40"
Duration="0:0:0.25"
Storyboard.TargetProperty="FontSize" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="ListBoxItem.MouseLeave">
<EventTrigger.Actions>
<!--<StopStoryboard BeginStoryboardName="aa"/>-->
<BeginStoryboard Name="aa1">
<Storyboard>
<ColorAnimation From="Red"
To="Black"
Duration="0:0:0.25"
Storyboard.TargetProperty="(ListBoxItem.Foreground).(SolidColorBrush.Color)" />
<DoubleAnimation To="25"
Duration="0:0:0.2"
Storyboard.TargetProperty="FontSize" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<!--绑定外部值 如下:-->
<!--<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:Window3},Path=IsSelected}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard Name="bb">
<Storyboard>
<ColorAnimation From="Green"
To="Yellow"
RepeatBehavior="Forever"
Duration="0:0:0.5"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=local:Window3},Path=IsSelected}" Value="false">
<DataTrigger.EnterActions>
<StopStoryboard BeginStoryboardName="bb" />
</DataTrigger.EnterActions>
</DataTrigger>-->
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<ListBox>
<ListBoxItem Content="001_我" />
<ListBoxItem Content="002_是" />
<ListBoxItem Content="003_鱼" />
<ListBoxItem Content="004_眼" />
<ListBoxItem Content="005_效" />
<ListBoxItem Content="006_果" />
<ListBoxItem Content="007_。" />
<ListBoxItem Content="008_酷~" />
</ListBox>
</Grid>
</Window>