title: How to handle a large amount of geometry data in a WPF drawing?
body: <p>I am drawing some items to a <code>DrawingGroup</code> in a WPF UI I am experimenting with, the code looks a little like this:</p>
  
  <pre><code>foreach( var path in allRoads ) 
  {
      var wpfPen = new Pen(brush, penSize);
      GeometryDrawing geometry = new GeometryDrawing();
      geometry.Pen = wpfPen;
      geometry.Geometry = GetPathGeometry(path);
      drawingGroup.Children.Add(geometry);
  }
  </code></pre>
  
  <p>This is called repeatedly as I draw in the various geometry items I am rendering ( I am adding them to the <code>DrawingGroup</code> then asking the <code>DrawingContext</code> to draw it afterwards ) but it gets into trouble and crashes out with the following message:</p>
  
  <blockquote>
    <p>The thread 0x3228 has exited with code 0 (0x0). Exception thrown:
    'System.OverflowException' in PresentationCore.dll An unhandled
    exception of type 'System.OverflowException' occurred in
    PresentationCore.dll The image data generated an overflow during
    processing.</p>
  </blockquote>
  
  <p>The crash seems to be happening just short of the 38000th geometry item ( all of them mult-point paths, some probably quite long as this is GIS data ) being added to the <code>DrawingGroup.Children</code> collection. </p>
  
  <p>I'm guessing that this is probably pushing the system past what it is designed for - is there a better way to handle this within WPF? Can it deal with a lot of geometry data and if not, whereabouts are the limits?</p>