0

I have some icon resources as DrawingImages that is made up of many GeometryDrawings. I have File MenuItems and ToolBar buttons that use these images via resource bindings to MenuItem.Icon. Unfortunately, only one of the MenuItems 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.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Ryan Cromwell
  • 2,613
  • 1
  • 17
  • 33

1 Answers1

3

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"]};
Nir
  • 29,306
  • 10
  • 67
  • 103
  • Turns out the problem was a mistake in using Image as the Resource element versus the DrawingImage. I didn't see the forest through the trees – Ryan Cromwell Dec 08 '09 at 15:01