Tech Off Post

Single Post Permalink

View Thread: I always get a black backgraound with DrawingContext in WPF
  • User profile image

    Are EllipseGeometry, RectangleGeometry, and the like shapes or drawingvisuals?

    Geometries are basically drawing commands which are executed by visuals, they aren't visuals themselfs. Shapes are visuals that contain only one geometry.

    And what does it matter if I use a canvas or not?

    Well, I'd say a canvas is simpler to use. And as AndyC said already, since you have to reimplement a number of things like hit testing, how do you know if your approach will be faster in the end? A quick test I did shows the following:

    • 1000 ellipses - both approaches render fast, the window resizes smoothly
    • 10000 ellipses - things starts to be slugish... in both cases
    • 100000 ellipses - ok, this means trouble... again, in both cases. Some profiling shows that >70% of CPU time is spent in milcore and the video driver, both are native components, they have no idea that you used a canvas or not.