** Dieses Projekt ist eine Fortsetzung des inaktiven Basisprojekts für andere Plattformen (WinUI/Uno.Skia.Wpf/Console) – https://github.com/hardcodet/wpf-notifyicon **
Dies ist eine Implementierung eines NotifyIcon (auch bekannt als Taskleistensymbol oder Taskleistensymbol) für .Net 6 WPF/WinUI/Uno.Skia.WPF/Console-Plattformen. Es basiert nicht nur auf der NotifyIcon-Komponente von Windows Forms, sondern ist ein völlig unabhängiges Steuerelement, das mehrere Funktionen der WPF/WinUI-Frameworks nutzt, um umfangreiche Tooltips, Popups, Kontextmenüs und Sprechblasenmeldungen anzuzeigen. Es kann direkt im Code verwendet oder in jede XAML-Datei eingebettet werden.
Install-Package H.NotifyIcon.Wpf
Install-Package H.NotifyIcon.WinUI
Install-Package H.NotifyIcon.Uno
Install-Package H.NotifyIcon.Uno.WinUI
# If you need other platforms, you can use this Core library -
# it allows you to make NotifyIcon even in a console application.
Install-Package H.NotifyIcon
< Window
xmlns : tb = " clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf " // WPF
xmlns : tb = " using:H.NotifyIcon " // WinUI
>
< tb : TaskbarIcon
ToolTipText = " ToolTip "
IconSource = " /Images/TrayIcons/Logo.ico "
ContextMenu = " {StaticResource TrayMenu} "
MenuActivation = " LeftOrRightClick "
TrayPopup = " {StaticResource TrayStatusPopup} "
PopupActivation = " DoubleClick "
TrayToolTip = " {StaticResource TrayToolTip} "
/>
</ Window >
Windows 11 führt ein neues Konzept namens Effizienzmodus ein.
Da diese Bibliothek grundsätzlich für Anwendungen gedacht ist, die im Hintergrund laufen und über TrayIcon interagieren können, implementiert die Bibliothek eine API für diesen Modus:
EfficiencyModeUtilities . SetEfficiencyMode ( bool value )
WindowExtensions . Hide ( this Window window , enableEfficiencyMode : true ) // default value
WindowExtensions . Show ( this Window window , disableEfficiencyMode : true ) // default value
TaskbarIcon . ForceCreate ( bool enablesEfficiencyMode = true ) // default value
Beispiel 1:
< tb : TaskbarIcon >
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " "
Foreground = " Red "
/>
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Beispiel 2:
< tb : TaskbarIcon
IconSource = " /Icons/Error.ico "
>
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " 5 "
Foreground = " Black "
FontSize = " 36 "
FontWeight = " Bold "
/>
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Beispiel 3:
< tb : TaskbarIcon >
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " "
Foreground = " Red "
FontFamily = " Segoe UI Emoji "
Background = " AliceBlue "
FontWeight = " Bold "
FontSize = " 38 "
/>
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Beispiel 4:
< tb : TaskbarIcon >
< tb : TaskbarIcon .IconSource>
< tb : GeneratedIconSource
Text = " "
BorderThickness = " 5 "
FontSize = " 46 "
>
< tb : GeneratedIconSource .Foreground>
< LinearGradientBrush StartPoint = " 0,0 " EndPoint = " 128,128 " >
< GradientStop Color = " White " />
< GradientStop Color = " Red " />
</ LinearGradientBrush >
</ tb : GeneratedIconSource .Foreground>
< tb : GeneratedIconSource .BorderBrush>
< LinearGradientBrush StartPoint = " 0,0 " EndPoint = " 128,128 " >
< GradientStop Color = " White " />
< GradientStop Color = " Red " />
</ LinearGradientBrush >
</ tb : GeneratedIconSource .BorderBrush>
</ tb : GeneratedIconSource >
</ tb : TaskbarIcon .IconSource>
</ tb : TaskbarIcon >
Es wird empfohlen, das Designer-Symbol anzuheften, damit es einfacher angezeigt werden kann. Gehen Sie dazu zu Taskleisteneinstellungen -> Andere Taskleistensymbole und aktivieren Sie dieses Symbol:
Derzeit sind drei Modi implementiert, von denen jeder seine eigenen Vor- und Nachteile hat.
Verfügbarkeit verschiedener Optionen (abhängig von der von Ihnen verwendeten Version von WindowsAppSDK
):
Option | Verpackte App | Unverpackte App |
---|---|---|
Transparenz | ab 1.1.0-Vorschau | ab 1.1.0-Vorschau |
Grenzenlos | ab 1.1.0-Vorschau | |
Animationen | , aber mit Grenzen | ab 1.1.0-Vorschau |
Untermenüs |
Vorrangiger Ort für Fehler: https://github.com/HavenDV/H.NotifyIcon/issues Vorrangiger Ort für Ideen und allgemeine Fragen: https://github.com/HavenDV/H.NotifyIcon/discussions Ich habe auch einen Discord Support-Kanal:
https://discord.gg/g8u2t9dKgE