OnStateChange() 时出现“气球提示文本必须具有非空值”异常。当我的应用程序最小化时调用此方法。
void OnStateChanged(object sender, EventArgs args)
{
try
{
if (WindowState == WindowState.Minimized)
{
Hide();
if (TippuTrayNotify != null)
{
TippuTrayNotify.Visible = true;
TippuTrayNotify.ShowBalloonTip(2000);
}
}
else
m_storedWindowState = WindowState;
}catch(Exception ex){
SystemLog.WriteLine("(Error) OnStateChange : "+ex.Message+" ;");
}
}
我在 MainWindow 构造函数中初始化 TippuTrayNotify
public MainWindow()
{
InitializeComponent();
TippuTrayNotify = new System.Windows.Forms.NotifyIcon();
TippuTrayNotify.Icon = new System.Drawing.Icon("Icons/icon_64.ico");
TippuTrayNotify.BalloonTipTitle = "OlivInClass";
TippuTrayNotify.Text = "OlivInClass";
TippuTrayNotify.DoubleClick += new EventHandler(TippuTrayNotify_DoubleClick);
}
请问有什么解决办法