我在我的项目中使用ZXing.Net.Mobile.Forms
。试过FreshMVVM和Prism。
ScannerXamlPage.xaml
<Grid>
<zxing:ZXingScannerView x:Name="ScannerView"
Result="{Binding ScanResult, Mode=OneWayToSource}"
ScanResultCommand="{Binding ProcessBarcodeCommand}"
IsScanning="{Binding IsScanning}"
IsAnalyzing="{Binding IsAnalyzing}" />
<zxing:ZXingDefaultOverlay x:Name="ScannerOverlay"
TopText="Hold your phone up to the QR code"
BottomText="Scanning will happen automatically"
ShowFlashButton="True"/>
这导致RuntimeException: getParameters failed
导航离开页面,然后返回到页面。 Related Github issue.
此解决方法暂时解决了这个问题:
protected override void OnDisappearing()
{
base.OnDisappearing();
Content = null;
}