<p>I have an images folder with a png in it.  I would like to set a MenuItem's icon to that png.  How do I write this in procedural code?</p>

[{'answer_id': 30285, 'author': 'Timothy Fries', 'author_id': 3163, 'author_profile': 'https://Stackoverflow.com/users/3163', 'pm_score': 7, 'selected': True, 'text': '<pre><code>menutItem.Icon = new System.Windows.Controls.Image \n       { \n           Source = new BitmapImage(new Uri("images/sample.png", UriKind.Relative)) \n       };\n</code></pre>\n'}, {'answer_id': 30287, 'author': 'Arcturus', 'author_id': 900, 'author_profile': 'https://Stackoverflow.com/users/900', 'pm_score': 5, 'selected': False, 'text': '<pre><code>&lt;MenuItem&gt;\n  &lt;MenuItem.Icon&gt;\n    &lt;Image&gt;\n      &lt;Image.Source&gt;\n        &lt;BitmapImage UriSource="/your_assembly;component/your_path_here/Image.png" /&gt;\n      &lt;/Image.Source&gt;\n    &lt;/Image&gt;\n  &lt;/MenuItem.Icon&gt;\n&lt;/MenuItem&gt;\n</code></pre>\n\n<p>Just make sure your image in also included in the project file and marked as resource, and you are good to go :)</p>\n'}, {'answer_id': 882961, 'author': 'awe', 'author_id': 109392, 'author_profile': 'https://Stackoverflow.com/users/109392', 'pm_score': 1, 'selected': False, 'text': '<p>This is how I used it (this way it dont need to be built into the assembly):  </p>\n\n<pre><code>MenuItem item = new MenuItem();\nstring imagePath = "D:\\\\Images\\\\Icon.png");\nImage icon = new Image();\nicon.Source= new BitmapImage(new Uri(imagePath, UriKind.Absolute));\nitem.Icon = icon;\n</code></pre>\n'}, {'answer_id': 1504419, 'author': 'IanR', 'author_id': 76116, 'author_profile': 'https://Stackoverflow.com/users/76116', 'pm_score': 4, 'selected': False, 'text': '<p>Arcturus\'s answer is good because it means you have the image file in your project rather than an independent folder.</p>\n\n<p>So, in code that becomes...</p>\n\n<pre><code>menutItem.Icon = new Image\n        {\n        Source = new BitmapImage(new Uri("pack://application:,,,/your_assembly;component/yourpath/Image.png"))\n        }\n</code></pre>\n'}, {'answer_id': 4578072, 'author': 'Mars', 'author_id': 560275, 'author_profile': 'https://Stackoverflow.com/users/560275', 'pm_score': -1, 'selected': False, 'text': "<p>You can also use your Visual Studio to insert a icon. This is the easiest way</p>\n\n<ul>\n<li>Right click at you project in the solution explorer</li>\n<li>chose Properties</li>\n<li>Make sure you're in the application page.</li>\n<li>@ recources you see: Icon and Manifest</li>\n<li>@ Icon: Click browse and pick your icon.</li>\n</ul>\n\n<p>Problem solved.</p>\n"}, {'answer_id': 14787183, 'author': 'Python Kid', 'author_id': 1451994, 'author_profile': 'https://Stackoverflow.com/users/1451994', 'pm_score': 0, 'selected': False, 'text': '<p>For those of you using vb.net, to do this you need to use this:\n<code>menuItem.Icon = New Image() With {.Source = New BitmapImage(New Uri("pack://application:,,,/your_assembly;component/yourpath/Image.png"))}</code></p>\n'}, {'answer_id': 17301152, 'author': 'Basti Endres', 'author_id': 2502838, 'author_profile': 'https://Stackoverflow.com/users/2502838', 'pm_score': 2, 'selected': False, 'text': '<p>This is a bit shorter :D</p>\n\n<pre><code>&lt;MenuItem Header="Example"&gt;\n   &lt;MenuItem.Icon&gt;\n      &lt;Image Source="pack://siteoforigin:,,,/Resources/Example.png"/&gt;\n   &lt;/MenuItem.Icon&gt;\n&lt;/MenuItem&gt;\n</code></pre>\n'}, {'answer_id': 19121780, 'author': 'Gary95054', 'author_id': 1807138, 'author_profile': 'https://Stackoverflow.com/users/1807138', 'pm_score': 1, 'selected': False, 'text': '<p>This is what worked for me</p>\n\n<pre><code>&lt;MenuItem Header="delete   ctrl-d" Click="cmiDelete_Click"&gt;\n    &lt;MenuItem.Icon&gt;\n        &lt;Image&gt;\n            &lt;Image.Source&gt;\n                &lt;ImageSource&gt;Resources/Images/delete.png&lt;/ImageSource&gt;\n            &lt;/Image.Source&gt;\n        &lt;/Image&gt;\n    &lt;/MenuItem.Icon&gt;\n&lt;/MenuItem&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/30239', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3047/']