I'm working on a project in Visual Studio using C# and WPF. I have a Datagrid and I would like to Programatically create/customize its context menu items.
Here is how I'm currently creating the menu item:
MenuItem Enable;
Enable = new MenuItem();
dgdProcessList.ContextMenu.Items.Add(Enable);
Enable.Header = "Enable";
Now I want to place a icon for that menu item, however I am having trouble figuring out how can I point the icon to an existing file in the project. It's currently located in Resources\Icons\SampleIcon.ico of my project. How do I properly reference it here:
Enable.Icon = ???;
Also, I would like this menu item to trigger a function when clicked. How do I do this with the following code:
Enable.Click = ???;
Apologies if this is something simple. I looked at various topics relating to this issue, but wasn't able to figure it out.