c# - WPF ContextMenu for tray icon -
i'm having wpf application can minimize tray. when normal-click it, window shows again.
now i'm wondering how create simple contextmenu
?
the contextmenu
has filled x options onclick run function. need 'exit'-item linked 'exit_click' method.
something i've tried is:
contextmenu menu = (contextmenu)this.findresource("notifiercontextmenu"); menu.isopen = true;
menu
doesn't know of isopen
value.
other examples use lot of different things. one of them requires me create hostmanager reason.
i need simple contextmenu
. how can achieve this?
as @h.b. mentioned hardcodet's notifyicon pretty darn wpf taskbar icons. sucks don't out of box wpf might use , address issue wait microsoft fix it(they should add library standards)
now solve issue(using above solution):
- download solution
- build library
- add source control if have 1 , add reference it(
hardcodet.wpf.taskbarnotification.dll
) in project
now in mainwindow.xaml have like:
<window ... xmlns:tb="http://www.hardcodet.net/taskbar" ...> ... <grid> <tb:taskbaricon> <tb:taskbaricon.contextmenu> <contextmenu> <menuitem click="exit_click" header="exit" /> </contextmenu> </tb:taskbaricon.contextmenu> </tb:taskbaricon> ... </grid> </window>
and mainwindow.xaml.cs click handler needed:
private void exit_click(object sender, routedeventargs e) { application.current.shutdown(); }
i recommend spending time looking @ examples coming source code of library familiarize available options. trust me wpf has way easy when comes helper libraries. try of qt helper libraries , you'll know "buried in there somewhere" literally means in opensource helpers.
Comments
Post a Comment