public App() { scanPage = new ZXingScannerPage(); scanPage.OnScanResult += (result) => { //System.Diagnostics.Debug.WriteLine("Scanned datamatrix code -> [" + result.Text + "]"); // Stop scanning scanPage.IsScanning = false; // Show the result Device.BeginInvokeOnMainThread(() => { scanPage.DisplayAlert("Scanned Barcode", result.Text, "OK"); }); }; //MainPage needs to be set, otherwise error MainPage = scanPage; }