Desktop Snow effect (ii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.