0

We have a path defined which we would like to render in several hundred different positions during the OnRender override. We know about the PushTransform method on the DC, but that seems to require a new TranslateTransform instance for each render, which means we end up with hundreds of TranslateTransform as well. That just doesn't seem efficient.

We've also tried a single TranslateTransform, then just changing it's X and Y locations with each render, but since WPF actually caches the drawing instructions and not the actual drawing, when it's finally time to render, they all render in the same location because they are sharing the same TranslateTransform using its last-set offsets.

So what's the best way to achieve this?

Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
  • "doesn't seem efficient" -> did you try this? Can't you create all TranslateTransforms once, and then for each render set their X and Y and then use them? – stijn Dec 17 '12 at 10:13
  • You won't get around having a distinct Transform object for each rendering of the Path. How else would you render the same Path object at different locations? – Clemens Dec 17 '12 at 11:51
  • @Clemens, back in the Win32 days, you could set the origin of your device context with an API call. Every drawing call thereafter would be relative to that origin. It's sort of like pushing all the TranslateTransforms except you were just setting a state, not creating all these objects. I was hoping there was some sort of 'SetOrigin' or even a 'SetRenderExtents' call in WPF but I guess not. – Mark A. Donohoe Dec 17 '12 at 14:48

0 Answers0