I have some icon resources as DrawingImage
s that is made up of many GeometryDrawing
s. I have File MenuItem
s and ToolBar
buttons that use these images via resource bindings to MenuItem.Icon
. Unfortunately, only one of the MenuItem
s show the icon.
I am sure you can't assign a single DrawingImage
resource to many MenuItem.Icon
(or anything else for that matter), but I don't know of an alternative. I would prefer not to duplicate the DrawingImage
resource, but if I have too I guess I will.
You assign an Image control to the Icon Property and set the DrawingImage into the Image.Source property.
In XAML:
<MenuItem>
<MenuItem.Icon>
<Image Source="{StaticResource myDrawingImage}"/>
</MenuItem.Icon>
<!-- everyhting else -->
</MenuItem>
In C#:
menuItem.Icon = new Image() {Source = (ImageSource)Resources["myDrawingImage"]};