我正在
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 } }
原文地址:https://www.jb51.cc/windows/364801.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。