Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在我的事件中检查发件人对象的.Text属性?_C#_Silverlight_Events_Event Handling - Fatal编程技术网

C# 如何在我的事件中检查发件人对象的.Text属性?

C# 如何在我的事件中检查发件人对象的.Text属性?,c#,silverlight,events,event-handling,C#,Silverlight,Events,Event Handling,如何使用sender.Text之类的内容查看单击按钮的.Text是什么?类似下面的伪代码: private void NuestroButton1_Click(object sender, RoutedEventArgs e) { if //the sender's .Text/.Content is X { //Do something System.Windows.Browser.HtmlPage.Window

如何使用sender.Text之类的内容查看单击按钮的.Text是什么?

类似下面的伪代码:

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");
       }

   }

只需一句话:在Silverlight中,Button没有文本属性,而是有内容属性(因为内容可以是任何东西,而不仅仅是文本)现在更少伪代码,更多代码(当然,我还缺少if-the cast if中的括号,如果重要的位。。。
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");
   }
}