Something like this then?
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
Line gradientLine;
LinearGradientBrush gradBrush = new LinearGradientBrush();
void Window_Loaded(object sender, RoutedEventArgs e)
{
gradBrush.GradientStops.Add(new GradientStop(Colors.Red, 0));
gradBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
gradBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 1));
gradBrush.GradientStops.Add(new GradientStop(Colors.Green, 1.5));
gradBrush.GradientStops.Add(new GradientStop(Colors.Blue, 2));
gradBrush.GradientStops.Add(new GradientStop(Colors.Indigo, 2.5));
gradBrush.GradientStops.Add(new GradientStop(Colors.Violet, 3));
gradBrush.GradientStops.Add(new GradientStop(Colors.Purple, 3.5));
gradientLine = new Line() { X1 = 0, Y1 = 0, X2 = 100, Y2 = 100, StrokeThickness = 1, Stroke = gradBrush };
cnvCanvas.Children.Add(gradientLine);
timer.Tick += timer_Tick;
timer.Interval = new TimeSpan(0, 0, 0, 0, 1000/30);
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
for (int i = 0; i < gradBrush.GradientStops.Count; ++i)
{
gradBrush.GradientStops[i].Offset = gradBrush.GradientStops[i].Offset - 0.01;
if (gradBrush.GradientStops[i].Offset < -1) gradBrush.GradientStops[i].Offset += 4;
}
}