private void NuestroButton1_Click(object sender, RoutedEventArgs e)
{
if //the sender's .Text/.Content is X
{
//Do something
System.Windows.Browser.HtmlPage.Window.Alert("Hello World");
}
}
如何使用sender.Text之类的东西来查看点击按钮的.Text是什么?
答案 0 :(得分:6)
类似下面的伪代码:
private void NuestroButton1_Click(object sender, RoutedEventArgs e)
{
Button foo = sender as Button; // Cast to the type we're expecting it to be
if( foo != null && foo.Content == "X" )
{
//Do something
System.Windows.Browser.HtmlPage.Window.Alert("Hello World");
}
}