Replies: 1 comment
-
For the background, since WPF image control does not have background property, you can do one of the following:
private DrawingGroup WrapDrawing(DrawingGroup currentDrawing)
{
var bounds = currentDrawing.Bounds;
var backgroundLayer = new DrawingGroup();
var backgroundBrush = new SolidColorBrush(Colors.Transparent);
backgroundBrush.SetValue(NameProperty, "backbrush"); // <===== Give it a name to help you control it.
var backgroundDrawing = new GeometryDrawing(backgroundBrush,
new Pen(Brushes.Red, 1), new RectangleGeometry(bounds)); // <===== Add a border color with a pen if you need it
backgroundLayer.Children.Add(backgroundDrawing);
var combinedDrawing = new DrawingGroup();
combinedDrawing.Children.Add(backgroundLayer);
combinedDrawing.Children.Add(currentDrawing);
return combinedDrawing;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use some svg images for buttons and want to have a press effect for it ... is it possible to change the background color of the svg image? I use the FileSvgReader to load the image ...
Beta Was this translation helpful? Give feedback.
All reactions