title: Why does use of pens with dash patterns cause huge (!) performance degredation in WPF custom 2D drawing?
body: <p>Hope anyone can shed light on this so I can use pens with dash patterns? </p>
  
  <p>I am writing a scrollable chart (a <code>Panel</code> inside <code>ScrollViewer</code> that implements <code>IScrollInfo</code>) in WPF using <code>DrawingVisual</code>'s <code>DataContext.Draw</code><em>X</em>. I have several thousand <code>DrawingVisual</code>s that get scrolled by using <code>TranslateTransform</code> on the <code>Panel</code> that hosts them. I implemented a grid by placing a <code>Panel</code> on top of it and drawing simple horizontal lines from one edge to the other using <code>DataContext.DrawLine(pen, new Point(0, y), new Point(widthOfPanel, y));</code> //(note: these lines are always static, they never move). </p>
  
  <p>The scroll performance is absolutely insane (i.e. DrawingVisual's are drawn instantly and scrolling is instant). But if I use a <code>Pen</code> that uses dash patterns (see below for example) to draw the grid lines, then scrolling is very jerky and the performance seems to have been decreased by a factor of 100 (an estimate). Can anyone explain why that happens and how I can workaround this?</p>
  
  <p>Example of Pen with dash pattern:</p>
  
  <pre><code>&lt;Pen x:Key="PenUsingDashPatterns" Brush="Black" Thickness="1"&gt;
     &lt;Pen.DashStyle &gt;
        &lt;DashStyle Dashes="3, 3" /&gt;
     &lt;/Pen.DashStyle&gt;
  &lt;/Pen&gt;
  </code></pre>