DrawingVisual performance with Opacity=0

前端 未结 4 1716
刺人心
刺人心 2021-01-13 19:54

If I have a DrawingVisual in WPF with Opacity=0, is that enough for it not to be drawn? We have hundreds of DrawingVisuals on a Canvas, and are currently setting Opacity=0 o

4条回答
  •  [愿得一人]
    2021-01-13 20:44

    The most efficient seems to be setting the opacity in my tests. Another simple approach is to redraw the visuals that are affected.

    using (DrawingContext dc = RenderOpen()) {} //Hide this visual
    

    And then redraw when they become visible again.

    Rendering a blank drawingcontext seems to be very quick. But if you have complicated visuals it could take time to rerender them when they become visible.

提交回复
热议问题