How do I use DrawingVisual object ?

Platform: WPF| Category: Visual Layer

In order to use DrawingVisual objects, you need to create a host container to store the DrawingVisual objects. Find the following code snippets,


[C#]
public class VisualHostContainer : FrameworkElement
{
    private VisualCollection _myVisualCollection;
 
    public VisualHostContainer()
    {
        _myVisualCollection = new VisualCollection(this);
        _myVisualCollection.Add(CreateDrawingVisualRectangle());
        _myVisualCollection.Add(CreateDrawingVisualText());
    }
}

Reference link: https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/using-drawingvisual-objects

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.