windows-8 – 在Windows 8应用程序中为DispatcherTimer的Tick事
发布时间:2020-12-14 04:11:09 所属栏目:Windows 来源:网络整理
导读:我正在 Windows 8 Visual Studio 11中开发一个应用程序,我想为DispatcherTimer实例定义一个事件处理程序,如下所示: public sealed partial class BlankPage : Page { int timecounter = 10; DispatcherTimer timer = new DispatcherTimer(); public BlankPa
我正在
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# (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- windows-server-2008 – 在Active Directory中禁
- microsoft-graph – 使用Microsoft Graph的userP
- active-directory – 在Active Directory中授予权
- 批处理文件 – 命令提示符中的全局变量
- windows server 2012 安装 VC14(VC2015) 安装失败
- 使用Windows Azure Service Bus进行邮件路由
- 没有外部依赖性的Windows GNU编译器套件
- windows-server-2008 – 与Windows 7和2008 Serv
- 代理后面的Windows 7上的Git Bash不再工作
- windows-server-2003 – 在Windows上从命令行确定
热点阅读