WPF Line 的颜色过度动画
<Line Grid.Column="2" Grid.ColumnSpan="2" VerticalAlignment="Center" Height="20" Width="auto" StrokeThickness="5" X1="0" Y1="10" X2="{Binding RelativeSource={RelativeSource Mode=Self},Path=ActualWidth}" Y2="10" x:Name="Line1"> <Line.Stroke> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" > <GradientStop Color="#FF94E894" Offset="0"/> <GradientStop Color="#FF94E894" Offset="0.8"/> <GradientStop Color="Black" Offset="0.8"/> <GradientStop Color="Black" Offset="1"/> </LinearGradientBrush> </Line.Stroke> <Line.Triggers> <EventTrigger RoutedEvent="Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="(Line.Stroke).(LinearGradientBrush.GradientStops)[1].(GradientStop.Offset)" BeginTime="00:00:00" Duration="00:00:5" From="0" To="1" AutoReverse="True" RepeatBehavior="Forever"/> <DoubleAnimation Storyboard.TargetProperty="(Line.Stroke).(LinearGradientBrush.GradientStops)[2].(GradientStop.Offset)" BeginTime="00:00:00" Duration="00:00:5" From="0" To="1" AutoReverse="True" RepeatBehavior="Forever"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Line.Triggers> </Line>
转载保留源出处即可,商业使用请自行鉴别,使用本博客中公开内容做任何违法犯罪于本作者无关