Open rfernandez opened 3 years ago
Thanks for sharing your work around. It worked for me, allowing the scanner view to work inside a XCT TabView.
This issue really needs more visibility.
May you post full code , please? Solution does not work.
This is my Custom ZXing `[assembly: ExportRenderer(typeof(VSR.Controls.MyZXingScannerView), typeof(VSR.Droid.ZXingScannerViewRenderer))] namespace VSR.Droid { internal class ZXingScannerViewRenderer : ZXing.Net.Mobile.Forms.Android.ZXingScannerViewRenderer { public ZXingScannerViewRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<ZXing.Net.Mobile.Forms.ZXingScannerView> e)
{
base.OnElementChanged(e);
formsView = Element;
//if (zxingSurface == null)
{
var currentContext = Android.App.Application.Context;
zxingSurface = new ZXingSurfaceView(currentContext, formsView.Options);
}
}
}
}`
This is my contentView with Custom ZXingView `<?xml version="1.0" encoding="utf-8" ?> <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:ZXing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms" xmlns:dxe="http://schemas.devexpress.com/xamarin/2014/forms/editors" xmlns:controls="clr-namespace:VSR.Controls" MinimumHeightRequest="500" x:Class="VSR.ScanPage">
I have an Android application with:
I am using the new TabView component. This component allows you to associate a view to each button. So I need to be able to use the Zxing component inside a ContentView.
The latest version of the Zxing component does not allow it to be used within a ContentView. It only works if you include it within a ContentPage. I have found a workaround by modifying the Android renderer
ZXingScannerViewRenderer
:To force this new renderer to use, I have copied the
ZXingScannerView
class into my common project with my namespace. In this way, I can already use the scanner from a view in XAML: