Hardcodet NotifyIcon for WPF

repository·develop·Indexed 21 days ago

https://github.com/hardcodet/wpf-notifyicon

A purely independent implementation of a system tray icon (NotifyIcon) for the WPF platform. It provides the TaskbarIcon control, allowing for rich tooltips, interactive popups, context menus, and custom balloon messages without wrapping Windows Forms.

Tokens
651
Snippets
1
Records
2
Agent score
26%

What's inside wpf-notifyicon

  1. Use TaskbarIcon in XAML

    develop

    The TaskbarIcon control can be embedded directly in XAML to provide a system tray icon with rich WPF features. You can configure its visibility, icon source, tooltips, context menus, and popup behavior using attached properties and standard WPF properties.

    To use it, declare the http://www.hardcodet.net/taskbar namespace in your XAML file.

    <Window
      x:Class="Hardcodet.NetDrives.UI.SystemTray.Sample"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:tb="http://www.hardcodet.net/taskbar">
    
        <tb:TaskbarIcon x:Name="myNotifyIcon"
                        Visibility="Visible"
                        ToolTipText="Fallback ToolTip for Windows xp"
                        IconSource="/Images/TrayIcons/Logo.ico"
                        ContextMenu="{StaticResource TrayMenu}"
                        MenuActivation="LeftOrRightClick"
                        TrayPopup="{StaticResoure TrayStatusPopup}"
                        PopupActivation="DoubleClick"
                        TrayToolTip="{StaticResource TrayToolTip}"
          />
    
    </Window>
  2. Configure TaskbarIcon properties

    develop

    The TaskbarIcon control supports several key properties for customizing the tray experience:

    • IconSource: Path to the icon file used in the system tray.
    • ToolTipText: Text for the fallback tooltip (used for older Windows versions).
    • TrayToolTip: A WPF resource defining a customized ToolTip.
    • ContextMenu: A standard WPF ContextMenu displayed when the icon is clicked.
    • MenuActivation: Determines which mouse click (e.g., LeftOrRightClick) triggers the ContextMenu.
    • TrayPopup: A WPF resource defining an interactive popup control.
    • PopupActivation: Determines which mouse click (e.g., DoubleClick) triggers the TrayPopup.
    • Visibility: Controls whether the icon is visible in the tray.