Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

If condition and buttons


How do i make a boolean variable for button clicks in xamarin?

private bool button1clicked = false;

private void button1(object sender, EventArgs e)
button1clicked = true;


The button doesn't work at all. But i think it makes sense, as i haven't described the id of the button anywhere. what went wrong?


  • MarshallMarshall USMember ✭✭

    what exactly are you trying to accomplish with this? are you just trying to find out if the button was clicked?

  • ChaseFlorellChaseFlorell CAInsider, University mod
    protected override void OnAppearing()
        var btn = new Button();
        btn.Clicked += (sender, args) = > ButtonClicked();
    private void ButtonClicked()
        // button was clicked
  • SimonLundSimonLund USMember

    Thank you! :D

Sign In or Register to comment.