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
You cannot access the x:Name property of a xaml element as this is just a hint for the compiler to name the variable.
What you can do however is to set the ClassId of your button so that you can retrieve it in the handler. Like this:
Your xaml :
Your xaml.cs
private void LoginButton_OnClicked(object sender, EventArgs e)
{
var button = (Button) sender;
var classId = button.ClassId;
}