0

We have a Canvas control that we have set to be very large such that when a user pans or zooms around they (very rarely) see the edge of the control.

This poses a number of issues. Firstly we have to render a very large surface with a lot going on which makes things slow. It also means a user could still accidentally "fall off" the edge of the ground plane.

I have tried creating any paths using StreamGeometries to make things faster and, where I can, I have frozen assets and set various objects to IsHitTestVisible = false. These have helped matters but at the end of the day we are still drawing a massive Canvas and WPF doesnt seem to be doing anything clever given the viewport

Can anyone offer some advice?

Simon Sarris
  • 62,212
  • 13
  • 141
  • 171
Chris
  • 26,744
  • 48
  • 193
  • 345
  • do you have to "draw" all bit's of the `Canvas`? Can't you maybe render the viewport dimension and keep the rest blank and when a scroll happens compute the new viewport and render that bit? – Viv Jul 10 '13 at 10:15
  • How do I go about doing that? – Chris Jul 10 '13 at 14:18
  • 1
    have a look at [Virtualized WPF Canvas](http://blogs.msdn.com/b/jgoldb/archive/2008/03/08/performant-virtualized-wpf-canvas.aspx), [SO answer](http://stackoverflow.com/a/126906/1834662). Search for "WPF Canvas Virtualisation", "WPF Canvas viewport only render". It's hard to give an exact step of instructions for such stuff. it's a matter of understanding what's available and applying it to meet your requirements as in these links there would definitely be things that you cannot do to meet your requirement. Just need to identify what you can use and derive ideas off that. – Viv Jul 10 '13 at 14:40

0 Answers0