Table of Contents

Class NotifyIcon

Namespace
Wpf.Ui.Tray.Controls
Assembly
Wpf.Ui.Tray.dll

Represents the implementation of icon in the tray menu as FrameworkElement.

public class NotifyIcon : FrameworkElement, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IQueryAmbient, IDisposable
Inheritance
NotifyIcon
Implements
Inherited Members

Examples

<tray:NotifyIcon
    Grid.Row="0"
    FocusOnLeftClick="True"
    Icon="pack://application:,,,/Assets/wpfui.png"
    MenuOnRightClick="True"
    TooltipText="WPF UI">
        <tray:NotifyIcon.Menu>
            <ContextMenu ItemsSource = "{Binding ViewModel.TrayMenuItems, Mode=OneWay}" />
        </tray:NotifyIcon.Menu>
</tray:NotifyIcon>

Constructors

NotifyIcon()

public NotifyIcon()

Fields

FocusOnLeftClickProperty

Identifies the FocusOnLeftClick dependency property.

public static readonly DependencyProperty FocusOnLeftClickProperty

Field Value

DependencyProperty

IconProperty

Identifies the Icon dependency property.

public static readonly DependencyProperty IconProperty

Field Value

DependencyProperty

LeftClickEvent

Identifies the LeftClick routed event.

public static readonly RoutedEvent LeftClickEvent

Field Value

RoutedEvent

LeftDoubleClickEvent

Identifies the LeftDoubleClick routed event.

public static readonly RoutedEvent LeftDoubleClickEvent

Field Value

RoutedEvent

MenuFontSizeProperty

Identifies the MenuFontSize dependency property.

public static readonly DependencyProperty MenuFontSizeProperty

Field Value

DependencyProperty

MenuOnRightClickProperty

Identifies the MenuOnRightClick dependency property.

public static readonly DependencyProperty MenuOnRightClickProperty

Field Value

DependencyProperty

MenuProperty

Identifies the Menu dependency property.

public static readonly DependencyProperty MenuProperty

Field Value

DependencyProperty

MiddleClickEvent

Identifies the MiddleClick routed event.

public static readonly RoutedEvent MiddleClickEvent

Field Value

RoutedEvent

MiddleDoubleClickEvent

Identifies the MiddleDoubleClick routed event.

public static readonly RoutedEvent MiddleDoubleClickEvent

Field Value

RoutedEvent

RightClickEvent

Identifies the RightClick routed event.

public static readonly RoutedEvent RightClickEvent

Field Value

RoutedEvent

RightDoubleClickEvent

Identifies the RightDoubleClick routed event.

public static readonly RoutedEvent RightDoubleClickEvent

Field Value

RoutedEvent

TooltipTextProperty

Identifies the TooltipText dependency property.

public static readonly DependencyProperty TooltipTextProperty

Field Value

DependencyProperty

Properties

Disposed

Gets or sets a value indicating whether the control is disposed.

protected bool Disposed { get; set; }

Property Value

bool

FocusOnLeftClick

Gets or sets a value indicating whether to focus the MainWindow on single left click.

public bool FocusOnLeftClick { get; set; }

Property Value

bool

HookWindow

public HwndSource? HookWindow { get; set; }

Property Value

HwndSource

Icon

public ImageSource Icon { get; set; }

Property Value

ImageSource

Id

public int Id { get; }

Property Value

int

IsRegistered

Gets a value indicating whether the icon is registered in the tray menu.

public bool IsRegistered { get; }

Property Value

bool

Menu

Gets or sets the context menu.

public ContextMenu? Menu { get; set; }

Property Value

ContextMenu

MenuFontSize

public double MenuFontSize { get; set; }

Property Value

double

MenuOnRightClick

Gets or sets a value indicating whether to show the Menu on single right click.

public bool MenuOnRightClick { get; set; }

Property Value

bool

ParentHandle

public IntPtr ParentHandle { get; set; }

Property Value

IntPtr

TooltipText

public string TooltipText { get; set; }

Property Value

string

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects.

Only unmanaged resources can be disposed.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

If disposing equals true, dispose all managed and unmanaged resources.

~NotifyIcon()

Finalizes an instance of the NotifyIcon class.

protected ~NotifyIcon()

OnLeftClick()

This virtual method is called when NotifyIcon is left-clicked and it raises the LeftClick event.

protected virtual void OnLeftClick()

OnLeftDoubleClick()

This virtual method is called when NotifyIcon is left-clicked and it raises the LeftDoubleClick event.

protected virtual void OnLeftDoubleClick()

OnMenuChanged(ContextMenu)

This virtual method is called when ContextMenu of NotifyIcon is changed.

protected virtual void OnMenuChanged(ContextMenu contextMenu)

Parameters

contextMenu ContextMenu

New context menu object.

OnMiddleClick()

This virtual method is called when NotifyIcon is left-clicked and it raises the MiddleClick event.

protected virtual void OnMiddleClick()

OnMiddleDoubleClick()

This virtual method is called when NotifyIcon is left-clicked and it raises the MiddleDoubleClick event.

protected virtual void OnMiddleDoubleClick()

OnRender(DrawingContext)

When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.

protected override void OnRender(DrawingContext drawingContext)

Parameters

drawingContext DrawingContext

The drawing instructions for a specific element. This context is provided to the layout system.

OnRightClick()

This virtual method is called when NotifyIcon is left-clicked and it raises the RightClick event.

protected virtual void OnRightClick()

OnRightDoubleClick()

This virtual method is called when NotifyIcon is left-clicked and it raises the RightDoubleClick event.

protected virtual void OnRightDoubleClick()

Register()

Tries to register the NotifyIcon in the shell.

public void Register()

Unregister()

Tries to unregister the NotifyIcon from the shell.

public void Unregister()

Events

LeftClick

Triggered when the user left-clicks on the Wpf.Ui.Tray.INotifyIcon.

public event RoutedNotifyIconEvent LeftClick

Event Type

RoutedNotifyIconEvent

LeftDoubleClick

Triggered when the user double-clicks the Wpf.Ui.Tray.INotifyIcon with the left mouse button.

public event RoutedNotifyIconEvent LeftDoubleClick

Event Type

RoutedNotifyIconEvent

MiddleClick

Triggered when the user middle-clicks on the Wpf.Ui.Tray.INotifyIcon.

public event RoutedNotifyIconEvent MiddleClick

Event Type

RoutedNotifyIconEvent

MiddleDoubleClick

Triggered when the user double-clicks the Wpf.Ui.Tray.INotifyIcon with the middle mouse button.

public event RoutedNotifyIconEvent MiddleDoubleClick

Event Type

RoutedNotifyIconEvent

RightClick

Triggered when the user right-clicks on the Wpf.Ui.Tray.INotifyIcon.

public event RoutedNotifyIconEvent RightClick

Event Type

RoutedNotifyIconEvent

RightDoubleClick

Triggered when the user double-clicks the Wpf.Ui.Tray.INotifyIcon with the right mouse button.

public event RoutedNotifyIconEvent RightDoubleClick

Event Type

RoutedNotifyIconEvent