If condition and buttons

Hi,

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


if(button1clicked)


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?

Posts

  • 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()
    {
        base.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.