Jan 082016
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’s not very difficult, so maybe the documentation is not too clear about it.
Create a folder in your project, for example “res” or “resources” or “images”. Put some graphics files in there by right-clicking on the folder, choosing Add and then choosing Add existing items.
To use these images in your XAML, follow this example:
1 2 3 4 5 | < MenuItem Header = "E_xit" Click = "btnCancel_Click" > < MenuItem.Icon > < Image Source = "Resources/Exit.png" Width = "20" /> </ MenuItem.Icon > </ MenuItem > |
In my project, the images are in the Resources folder. And that’s all there is to it.