I'm making a route planner program in WPF and I need to display a map that is a graph object with tens of thousands of edges. What would be the best option for drawing these lines if I also want to interact with this map (like zooming, moving, selecting edges)? All the options I tried turned out to hova really slow rendering performance.
You can use the Shape , interact with these object is particularly simple, but if you are dealing with thousands of edges I suggest to use the DrawingVisual class, a visual object that can be used to render vector graphics on the screen, and its RenderOpen method. I had a similar problem to yours and I have improved the performance of my application using DrawingContext to draw my edges.
To zoom you have to work with transformations, in particular ScaleTrasnform and apply the transformation to your panel or to your shapes.
DrawingVisual does not provide event handlig, so if with Shape you can use events to interact with edges, with DrawingVisual you need to implement Hit-Testing .
To improve drawing performance you have to avoid rendering all lines at once. You could not improve your performance even using lower level visuals.
You have to follow these things:
If you have to use WPF, then take a look at the DrawingVisual class. This gives access to low-level drawing primitives which will give faster performance. However, as you are dealing with lower level objects, you'll have to deal with things like focus and hit-testing yourself. Take a look here for msdn entries on DrawingVisuals:
http://msdn.microsoft.com/en-us/library/system.windows.media.drawingvisual.aspx http://msdn.microsoft.com/en-us/library/ms742254.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.