Get control name in Button event handler method Xamarin Forms

前端 未结 3 726
不知归路
不知归路 2021-01-05 04:47

I have 20 buttons in my Xamarin Forms app . All of the buttons share the same click event method. What I want to do is use switch statement to check the button name but I am

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 05:26

    Maybe this can help you

    if(sender is Button){
    
       Button button = (Button)sender;
       if(button.Equals(myButton1)){
          // You are in myButton1
       }else if(button.Equals(myButton2)){
       }
    }
    

提交回复
热议问题