C#, WPF NotifyIcon, context menu and application exit« Wróć do listy pytań
exmple code
|
▲ ▼ |
var contextmenu = new ContextMenu(); MenuItem mi = new MenuItem(); mi.Header = "Close App"; mi.Click += (sender, args) => { this.Close(); Environment.Exit(0); }; var itm = contextmenu.Items.Add(mi); var TaskbarIcon tb = new TaskbarIcon(); tb.ToolTipText = "Test test test"; tb.Icon = (Icon)Properties.Resources.ikonaone; tb.TrayMouseDoubleClick += NotifyIconInteracted; tb.ContextMenu = contextmenu; |