Add system tray icon and cancel taskbar icon
1. Cancel taskbar icon
Startup Window setting showintaskbar= "False"
<window x:class="Snoweffect.mainwindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"Background="Transparent"WindowState="maximized"WindowStyle="None"ShowInTaskbar="False"ishittestvisible="False"allowstransparency="True"DataContext="{Binding Main, Source={staticresource Locator}}"> <grid x:name="LayoutRoot"Background="Transparent"/></window>
2. Add the system tray icon
New Systemnotifyicon Class
/// <summary> ///system tray icon/// </summary> Internal classSystemnotifyicon {/// <summary> ///Add System Tray/// </summary> Internal Static voidAddsystemnotifyicon () {NewNotifyIcon {Text=Properties.Resources.SnowFlower, Visible=true, Icon=System.Drawing.Icon.ExtractAssociatedIcon (System.Windows.Forms.Application.ExecutablePath), Contextme Nu=NewContextMenu (Getsystemnotifyiconcontextmenuitems ())}; } //get the right-click context menu for the system tray Private Staticmenuitem[] Getsystemnotifyiconcontextmenuitems () {varShutdownitem =NewMenuItem {Text=Properties.Resources.Shutdown}; Shutdownitem.click+ = (sender, args) = ={System.Windows.Application.Current.Shutdown ();}; varresult =New[] {shutdownitem}; returnresult; } }
Calling Methods in App.xaml.cs
Public Partial class App { static App () { dispatcherhelper.initialize (); Systemnotifyicon.addsystemnotifyicon (); } }
Source
Desktop Snow effect (ii)