Get control name in Button event handler method Xamarin Forms

前端 未结 3 746
不知归路
不知归路 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 05:40

    var btn = (Button)sender;
    
    if(btn.Id == btn1.Id) {
    
    }
    else if(btn.Id == btn2.Id){
    }
    

提交回复
热议问题