{"id":1804,"date":"2016-01-08T12:39:45","date_gmt":"2016-01-08T11:39:45","guid":{"rendered":"http:\/\/www.switchbl8.nl\/blog\/?p=1804"},"modified":"2016-01-08T13:03:31","modified_gmt":"2016-01-08T12:03:31","slug":"menuitem-with-icons","status":"publish","type":"post","link":"https:\/\/www.switchbl8.nl\/blog\/2016\/01\/menuitem-with-icons\/","title":{"rendered":"MenuItem with Icons"},"content":{"rendered":"<p>I was looking for icons to use in MenuItems in a WPF menu and found that there are a lot of questions on how to do that. It&#8217;s not very difficult, so maybe the documentation is not too clear about it.<\/p>\n<p>Create a folder in your project, for example &#8220;res&#8221; or &#8220;resources&#8221; or &#8220;images&#8221;. Put some graphics files in there by right-clicking on the folder, choosing Add and then choosing Add existing items.<\/p>\n<p>To use these images in your XAML, follow this example:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n &lt;MenuItem Header=&quot;E_xit&quot; Click=&quot;btnCancel_Click&quot;&gt;\r\n   &lt;MenuItem.Icon&gt;\r\n    &lt;Image Source=&quot;Resources\/Exit.png&quot; Width=&quot;20&quot; \/&gt;\r\n  &lt;\/MenuItem.Icon&gt;\r\n&lt;\/MenuItem&gt;\r\n<\/pre>\n<p>In my project, the images are in the Resources folder. And that&#8217;s all there is to it. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was looking for icons to use in MenuItems in a WPF menu and found that there are a lot of questions on how to do that. It&#8217;s not very difficult, so maybe the documentation is not too clear about it. Create a folder in your project, for example &#8220;res&#8221; or &#8220;resources&#8221; or &#8220;images&#8221;. Put <a href='https:\/\/www.switchbl8.nl\/blog\/2016\/01\/menuitem-with-icons\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[128,92,138,81],"class_list":["post-1804","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c","tag-development-2","tag-microsoft","tag-tips","category-1-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/posts\/1804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/comments?post=1804"}],"version-history":[{"count":7,"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/posts\/1804\/revisions"}],"predecessor-version":[{"id":1811,"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/posts\/1804\/revisions\/1811"}],"wp:attachment":[{"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/media?parent=1804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/categories?post=1804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.switchbl8.nl\/blog\/wp-json\/wp\/v2\/tags?post=1804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}