I want to programmatically add a context menu to my tray icon so that when I right-click on the tray icon, it should show me the menu. How should I write a right-click event handler for the tray icon?
I tried the following:
private void Icon_MouseRightClick(object sender, MouseButtonEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left)
Eventhandler is declared as,
NotifyIcon.MouseRightClick += new MouseButtonEventHandler(NotifyIcon_MouseRightClick);
c # wpf contextmenu right-click trayicon
user2622971
source share