I have a DrawingVisual object and I want to change its fill and its stroke.
I’ve tried this for Fill:
DrawingVisual MyDrawing = new DrawingVisual();
SetFill(Brushes.Red, MyDrawing.Drawing);
Where SetFill is:
private void SetFill(Brush fill, DrawingGroup group)
{
foreach (Drawing drw in group.Children)
{
if (drw is DrawingGroup)
SetFill(fill, drw as DrawingGroup);
else if (drw is GeometryDrawing)
{
GeometryDrawing geo = drw as GeometryDrawing;
geo.Brush = fill;
using (DrawingContext context = MyDrawing.RenderOpen())
{
context.DrawDrawing(group);
}
}
}
}
But in this way may happen that my DrawingVisual is drawn to a different position, as if the transformations have not been applied more (to MyDrawing).
How can I do?
Thanks.
This entry was posted in Codes & Scripts and tagged Changing, contour, DrawingVisual, surface. Bookmark the permalink.