wpf - Using a DrawingImage as Icon for Multiple MenuItems -


I have some icon resources because DrawingImage s is composed of many GeometryDrawing < / Code> s I have the file menu item s and toolbar buttons that use these images through the resource binding on the MenuItem.Icon . Unfortunately, only shows an icon from menu s

I'm sure that you have many DrawingImage resources in many MenuItem.Icon (or something else for that matter), but I do not know an option I do not like to duplicate the drawing resource, but if I think that I am also looks like.

You assign an image control to the icon property and set DrawingImage in the picture. Source Property

In XAML:

  & lt; MenuItem & gt; & Lt; MenuItem.Icon & gt; & Lt; Image Source = "{StaticResource myDrawingImage}" /> & Lt; /MenuItem.Icon> & Lt ;! - Everything else - & gt; & Lt; / MenuItem & gt;  

C #:

  menuItem.Icon = new Image () {source = (ImageSource) resource ["myDrawingImage"]};  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -