我书面方式在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.