windows-8 – 在Windows 8应用程序中为DispatcherTimer的Tick事件定义事件处理程序

我正在 Windows 8 Visual Studio 11中开发一个应用程序,我想为dispatcherTimer实例定义一个事件处理程序,如下所示:
public sealed partial class BlankPage : Page
    {

        int timecounter = 10;
        dispatcherTimer timer = new dispatcherTimer();
        public BlankPage()
        {
            this.InitializeComponent();
            timer.Tick += new EventHandler(HandleTick);
        }

        private void HandleTick(object s,EventArgs e)
        {

            timecounter--;
            if (timecounter ==0)
            {
                //disable all buttons here
            }
        }
        .....
}

但是我得到以下错误

Cannot implicitly convert type 'System.EventHandler' to 'System.EventHandler<object>'

我是widows 8应用程序的新手开发者.

你能帮帮我吗?

几乎拥有它:)你不需要实例化一个新的eventhandler对象,你只需要指向处理事件的方法.因此,一个事件处理程序.
int timecounter = 10;
    dispatcherTimer timer = new dispatcherTimer();
    public BlankPage()
    {
        this.InitializeComponent();

        timer.Tick += timer_Tick;
    }

    protected void timer_Tick(object sender,object e)
    {
        timecounter--;
        if (timecounter == 0)
        {
            //disable all buttons here
        }
    }

尝试阅读代表以了解事件Understanding events and event handlers in C#

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...