mauiqgraphicsview

Append elements to .net maui GraphicsView Control


Is it possible to append additional elements (shape or image) to a .NET MAUI GraphicsView Control without having to perform a refresh? I'm writing an app that will use the GraphicsView control. Initially it will be empty. As the user enter data, an element will be added. Sometime later another element may be added as needed. As each element is added will I have to erase everything on the GraphicsView control and redraw everything, or can I add a single element without have to refresh the GraphicsView control?


Solution

  • In the MAUI GraphicsView, When you have changed its content while it's still visible, the Invalidate method is needed to inform the canvas that it needs to redraw itself. And this method must be invoked on a GraphicsView instance, like the following code:

    graphicsView.Invalidate();
    

    For more specific details, you can refer to Invalidate the canvas.