Display a notification icon in the system tray. C#


SUBMITTED BY: abmrasel

DATE: June 26, 2017, 4:30 p.m.

FORMAT: C++

SIZE: 1.2 kB

HITS: 386

  1. Display a notification icon in the system tray. C#
  2. ==================================================
  3. <Window x:Class="NotificationIconSample.MainWindow"
  4. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  5. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  6. Title="NotificationIconSample" Height="300" Width="300">
  7. <Grid>
  8. <Button Click="click">Click</Button>
  9. </Grid>
  10. </Window>
  11. //File:Window.xaml.cs
  12. namespace NotificationIconSample
  13. {
  14. using System;
  15. using System.Windows;
  16. using System.Windows.Forms;
  17. using System.Drawing;
  18. public partial class MainWindow : Window
  19. {
  20. NotifyIcon notifyIcon;
  21. public MainWindow()
  22. {
  23. InitializeComponent();
  24. }
  25. void click(object sender, RoutedEventArgs e)
  26. {
  27. this.notifyIcon = new NotifyIcon();
  28. this.notifyIcon.BalloonTipText = "Hello, NotifyIcon!";
  29. this.notifyIcon.Text = "Hello, NotifyIcon!";
  30. this.notifyIcon.Icon = new System.Drawing.Icon("NotifyIcon.ico");
  31. this.notifyIcon.Visible = true;
  32. this.notifyIcon.ShowBalloonTip(1000);
  33. }
  34. }
  35. }

comments powered by Disqus