WPF中特定时间的弹出窗口? [英] PopUp window on a specific time in WPF?

查看:32
本文介绍了WPF中特定时间的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 WPF 中的特定时间创建和显示弹出窗口?我的意思是如何在系统托盘一侧显示窗口.

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.

推荐答案

如果您想在特定的小时/秒/分钟(或计算多少小时/还剩几秒/分钟,直到您的特定时间到来).

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
    // ......
}

<小时>

好的,所以你也想知道如何做一个通知弹出类型的事情,这可能是 CodeProject 可能会有所帮助.

这篇关于WPF中特定时间的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆