Articles in this section
Category / Section

How to set the Notify icon on the mouse position?

1 min read

The NotifyIcon can be placed at the Mouse Position by using the BalloonTipLocation property.


The BalloonTipLocation property is used to set the desired location for the NotifyIcon to be displayed. To set the NotifyIcon at the MousePoint, you need to get the Mouse Position Coordinates of the control by using the Mouse.GetPosition () method and then set the Coordinates at the BalloonTipLocation property of the NotifyIcon.

The following code example shows how to set the NotifyIcon at the Mouse Position:


public partial class MainWindow : Window
        public Point MousePoint;
        public MainWindow()
            NotifyIcon notifyicon = new NotifyIcon();  
            notifyIcon.Background = Brushes.AliceBlue;
            notifyIcon.BalloonTipText = "CustomNotifyIcon Created";   
            Button Button1 = new Button1();
            Button1.Content="Show NotifyIcon";
            Button1.Click += Buttonclick;   
            Button1.PreviewMouseDown += Button1_PreviewMouseDown;                            
 //Getting the Mouse point: 
      private void Button1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
           MousePoint = Mouse.GetPosition(this);      
 //Setting the Mouse position for the NotifyIcon:  
     private void Buttonclick(object sender, EventArgs e)
         notifyicon.BalloonTipLocation = new Point(MousePoint.X, MousePoint.Y);


The following output is rendered and shows that the NotifyIcon is created at the Mouse Position.

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment