设置单一事件处理程序在.NET多按钮? [英] Set up single event handler for multiple buttons in .NET?

查看:185
本文介绍了设置单一事件处理程序在.NET多按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我书面方式在Silverlight应用程序/ C#由13,当点击执行一个简单的导航到另一个页面永久按钮。

An application I'm writting in silverlight/c# consists of 13 permanent buttons that when clicked perform a simple navigation to another page.

问题是我的code后面有13个不同的事件处理程序(的code很多)的几乎相同的目的。

The problem is my code behind has 13 different event handlers(alot of code) for a nearly identical purpose.

有没有一种方法来检测哪个按钮是pressed,这样一个单一的事件处理程序被炒鱿鱼,​​和一个简单的if语句中可以决定去?

Is there a way to detect which button was pressed so that a single event handler gets fired, and a simple if statement within could determine which page to go to?

推荐答案

是:你可以用同样的方法对所有按钮和使用参数发件人作为sender.Name获得的$ P名$ pssed按钮。

yes: you can use the same method for all buttons, and use the parameter "sender" as "sender.Name" to get the name of the pressed button.

这篇关于设置单一事件处理程序在.NET多按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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