PopUp window on a specific time in WPF?

江枫思渺然 提交于 2019-12-24 00:08:41

问题


How can I create and show a popup window at a specific time in WPF? What I mean how to display the window on the side of system tray.


回答1:


You could use a timer if you're trying to make the thing popup in a certain number of hours/seconds/minutes (or work out how many hours/seconds/minutes are left until your specific time comes around).

private System.Windows.Threading.DispatcherTimer popupTimer;

// Whatever is going to start the timer - I've used a click event
private void OnClick(object sender, RoutedEventArgs e)
{
    popupTimer = new System.Windows.Threading.DispatcherTimer();

    // Work out interval as time you want to popup - current time
    popupTimer.Interval = specificTime - DateTime.Now;
    popupTimer.IsEnabled = true;
    popupTimer.Tick += new EventHandler(popupTimer_Tick);
}

void popupTimer_Tick(object sender, EventArgs e)
{
    popupTimer.IsEnabled = false;
    // Show popup
    // ......
}

Ok, so you also want to know how to do a notifier popup type thing, which maybe this article in CodeProject might help.




回答2:


Check out this question for firing an event at a set time.




回答3:


You might want to check out DispatcherTimer.



来源:https://stackoverflow.com/questions/938464/popup-window-on-a-specific-time-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!