I am working on a plugin (using System.ComponentModel.Composition
) for an application to place an icon in the notification area of the Windows UI.
trayMenu.MenuItems.Clear();
// Create context menu items
foreach( IJob job in jobs ) {
MenuItem menuItem = new MenuItem( job.Name ) {Tag = job};
menuItem.Click += MenuItemClick;
trayMenu.MenuItems.Add( menuItem );
}
private void MenuItemClick( object sender, EventArgs e ) {
// ...
}
Now when I click on an item in the context menu of that icon, the Click
handler is not being invoked.
Interestingly though, when I right-click the icon again (after having clicked a menu item) the Click
handler for the previously clicked MenuItem
is invoked. Left-clicking or hovering over the icon does not trigger this step.
What is going on?
Update: I have a strong feeling my problem is related to this question. But I'm still trying to figure out how I could apply that to my plugin/application.