Answer the question
In order to leave comments, you need to log in
Why can't I set the color of the GeometryDrawing.Brush brush, is it throwing an exception?
public void LoadIcon(object obj)
{
DrawingBrush brush = obj as DrawingBrush;
DrawingGroup dgroup = brush.Drawing as DrawingGroup;
foreach (var item in dgroup.Children)
{
var geometry = item as GeometryDrawing;
// Это часть вызывает исключение
geometry.Brush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
};
IconButton = brush;
}
Answer the question
In order to leave comments, you need to log in
Your GeometryDrawing (most likely DrawingGroup and DrawingBrush too) are in a "frozen" state. In this state, nothing can be changed in them, and they work more efficiently. You can check this by looking at the value of the IsFrozen property . It's best to remove their freezing, but if that's problematic, you can make an editable copy of the DrawingBrush with the Clone method .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question