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