#232 – The DrawingVisual Class
March 1, 2011 Leave a comment
DrawingVisual is a lightweight class that can be used a base class for new controls that need to render (draw) a collection of 2D primitives on the screen. It inherits from the Visual class, which gives it support for things like hit testing and coordinate transformations. It also inherits from ContainerVisual, which manages a collection of separate Visual objects.
You draw in a DrawingVisual object by calling its RenderOpen method to get a DrawingContext and then by calling methods on the DrawingContext to draw the 2D content.
The Drawing property of the DrawingVisual represents the collection of 2D objects that have been drawn, each of which is a Drawing object.
In order to actually display the content of a DrawingVisual object in a window or page, it must be hosted inside an UIElement or FrameworkElement.