/// <summary> /// Draw graphics object /// </summary> public override void Draw(DrawingContext drawingContext) { drawingContext.DrawRectangle( null, new Pen(Brushes.White, ActualLineWidth), Rectangle); var dashStyle = new DashStyle(); dashStyle.Dashes.Add(5); var dashedPen = new Pen(Brushes.Black, ActualLineWidth) { DashStyle = dashStyle }; var animation = new DoubleAnimation { BeginTime = new TimeSpan(0, 0, 0), RepeatBehavior = RepeatBehavior.Forever, From = 0, To = 20 }; dashStyle.BeginAnimation(DashStyle.OffsetProperty, animation); drawingContext.DrawRectangle( null, dashedPen, Rectangle); }