title: Programmatically click a button in Xamarin.Forms
body: <p>I have 2 buttons on a xamarin form, </p>
  
  <p>scannerButton and checkOrderButton</p>
  
  <p>scannerButton opens the scanner page, scans a QRCode and populates it into a order entry field </p>
  
  <p>checkOrderButton reads whatever is in the order entry field and processes validations and sends it to server for verification</p>
  
  <p>what I want - is to call the checkOrderButton.Click from within the scannerButton.Click - after it has scanned the text</p>
  
  <p>code:</p>
  
  <pre><code>private async void scanCameraButton_Clicked(object sender, EventArgs e)
  {
      var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
      options.PossibleFormats = new List&lt;ZXing.BarcodeFormat&gt;() {
          ZXing.BarcodeFormat.QR_CODE,ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13
      };
  
      var scanPage = new ZXingScannerPage(options);
      scanPage.OnScanResult += (result) =&gt;
      {
          //stop scan
          scanPage.IsScanning = false;
  
          Device.BeginInvokeOnMainThread(() =&gt;
          {
              //pop the page and get the result
              Navigation.PopAsync();
              orderNoEntry.Text = result.Text;
          });
  
              //invoke checkOrderButton.Click here
  
      };
  </code></pre>
  
  <p>what would be the best approach to do this?</p>
  
  <p>one alternate is to dump all the functionality from checkOrderButton.Click handler into a function and then call that function from both button clicks, but I'm interested in learning how I can invoke the click event programmatically</p>