I'm looking at the sample for ZXing.net for Xamarin.Forms and it's using a code only approach to scanning the barcode.
I used this question as inspiration to get the following code, but I'm not entirely sure how to manage the scan event while using Prism.
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:zx="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
xmlns:zxcm="clr-namespace:ZXing.Common;assembly=zxing.portable"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WebOfTrust.Views.Client.MyPeople.ScanNewOrUpdateContact">
<ContentPage.Content>
<StackLayout>
<zx:ZXingDefaultOverlay
TopText= " Hold your phone up to the barcode"
BottomText=" Scanning will being automatically">
</zx:ZXingDefaultOverlay>
<!-- BarcodeValue="{Binding QrCode}" -->
<zx:ZXingScannerView
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
</zx:ZXingScannerView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
My question is, how do I design a page so that I can catch the OnScanResult as demonstrated in the sample (copied below)
zxing.OnScanResult += (result) =>
Device.BeginInvokeOnMainThread (async () => {
// Stop analysis until we navigate away so we don't keep reading barcodes
zxing.IsAnalyzing = false;
// Show an alert
await DisplayAlert ("Scanned Barcode", result.Text, "OK");
// Navigate away
await Navigation.PopAsync ();
});
Refer to the following code: