Class NotifyIcon
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
IconProperty
Identifies the Icon dependency property.
public static readonly DependencyProperty IconProperty
Field Value
LeftClickEvent
Identifies the LeftClick routed event.
public static readonly RoutedEvent LeftClickEvent
Field Value
LeftDoubleClickEvent
Identifies the LeftDoubleClick routed event.
public static readonly RoutedEvent LeftDoubleClickEvent
Field Value
MenuFontSizeProperty
Identifies the MenuFontSize dependency property.
public static readonly DependencyProperty MenuFontSizeProperty
Field Value
MenuOnRightClickProperty
Identifies the MenuOnRightClick dependency property.
public static readonly DependencyProperty MenuOnRightClickProperty
Field Value
MenuProperty
Identifies the Menu dependency property.
public static readonly DependencyProperty MenuProperty
Field Value
MiddleClickEvent
Identifies the MiddleClick routed event.
public static readonly RoutedEvent MiddleClickEvent
Field Value
MiddleDoubleClickEvent
Identifies the MiddleDoubleClick routed event.
public static readonly RoutedEvent MiddleDoubleClickEvent
Field Value
RightClickEvent
Identifies the RightClick routed event.
public static readonly RoutedEvent RightClickEvent
Field Value
RightDoubleClickEvent
Identifies the RightDoubleClick routed event.
public static readonly RoutedEvent RightDoubleClickEvent
Field Value
TooltipTextProperty
Identifies the TooltipText dependency property.
public static readonly DependencyProperty TooltipTextProperty
Field Value
Properties
Disposed
Gets or sets a value indicating whether the control is disposed.
protected bool Disposed { get; set; }
Property Value
FocusOnLeftClick
Gets or sets a value indicating whether to focus the MainWindow on single left click.
public bool FocusOnLeftClick { get; set; }
Property Value
HookWindow
public HwndSource? HookWindow { get; set; }
Property Value
Icon
public ImageSource Icon { get; set; }
Property Value
Id
public int Id { get; }
Property Value
IsRegistered
Gets a value indicating whether the icon is registered in the tray menu.
public bool IsRegistered { get; }
Property Value
Menu
Gets or sets the context menu.
public ContextMenu? Menu { get; set; }
Property Value
MenuFontSize
public double MenuFontSize { get; set; }
Property Value
MenuOnRightClick
Gets or sets a value indicating whether to show the Menu on single right click.
public bool MenuOnRightClick { get; set; }
Property Value
ParentHandle
public IntPtr ParentHandle { get; set; }
Property Value
TooltipText
public string TooltipText { get; set; }
Property Value
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
~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
ContextMenuNew 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
DrawingContextThe 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
LeftDoubleClick
Triggered when the user double-clicks the Wpf.Ui.Tray.INotifyIcon with the left mouse button.
public event RoutedNotifyIconEvent LeftDoubleClick
Event Type
MiddleClick
Triggered when the user middle-clicks on the Wpf.Ui.Tray.INotifyIcon.
public event RoutedNotifyIconEvent MiddleClick
Event Type
MiddleDoubleClick
Triggered when the user double-clicks the Wpf.Ui.Tray.INotifyIcon with the middle mouse button.
public event RoutedNotifyIconEvent MiddleDoubleClick
Event Type
RightClick
Triggered when the user right-clicks on the Wpf.Ui.Tray.INotifyIcon.
public event RoutedNotifyIconEvent RightClick
Event Type
RightDoubleClick
Triggered when the user double-clicks the Wpf.Ui.Tray.INotifyIcon with the right mouse button.
public event RoutedNotifyIconEvent RightDoubleClick