ZXing.Net.Mobile view does not stretch for UWP in Xamarin.Forms -


i use zxing.net.mobile zxingscannerview in xamarin.forms application. test android api 21+ , windows mobile 10. while in android camera stream expands boundaries of scanner view perfectly, not true uwp. no matter emulator size or resolution. i"ve tried real windows phone device , issue still appears.

i place zxingscannerview in content page similar this:

<contentpage.content>     <stacklayout spacing="20" padding="15">         ...         <grid             horizontaloptions="fillandexpand"             verticaloptions="fillandexpand">             <zxing:zxingscannerview                 x:name="zxing"                 result="{binding scannerresult, mode=twoway}"                 isscanning="{binding scannerscanning}"                 isvisible="{binding scannervisible}"                 isanalyzing="{binding scanneranalyzing}"                 scanresultcommand="{binding scannedcommand}"/>             <v:mainpagezxingoverlayview />         </grid>         ...     </stacklayout> </contentpage.content> 

also i've noticed view .xaml has capture element set stretch="fill"

 <captureelement           grid.row="0"         grid.column="0"         x:name="captureelement"           stretch="fill" /> 

also in view .cs

// *after* preview setup, set ui layout happens // otherwise preview gets stuck in funny place on screen captureelement.stretch = stretch.uniformtofill; 

anyone experiencing same problem or have fix it?

while in android camera stream expands boundaries of scanner view perfectly, not true uwp. no matter emulator size or resolution. i"ve tried real windows phone device , issue still appears.

the preview resolution set based on camera resolution when camera start scan.

for requirement, expand preview boundaries via custom camera resolution. please refer following code :

private async void button_clicked(object sender, eventargs e) {                     var options = new zxing.mobile.mobilebarcodescanningoptions     {         cameraresolutionselector = handlecameraresolutionselectordelegate     };     var scanner = new zxing.mobile.mobilebarcodescanner();     scanner.autofocus();     var result = await scanner.scan(options);     if (result != null)         system.diagnostics.debug.writeline("scanned barcode: " + result.text); } cameraresolution handlecameraresolutionselectordelegate(list<cameraresolution> availableresolutions) {     //don't know if ever null or empty     if (availableresolutions == null || availableresolutions.count < 1)         return new cameraresolution() { width = 800, height = 600 };      //debugging revealed last element in list     //expresses highest resolution. more thorough.     return availableresolutions[availableresolutions.count - 1]; } 

enter image description here

update

note i'm using zxingscannerview itself, not built-in wrappers. i've updated question more clear.

if use zxingscannerview, modify zxingscannerview options in code behind.

public mainpage() {     initializecomponent();     var options = new zxing.mobile.mobilebarcodescanningoptions     {         cameraresolutionselector = handlecameraresolutionselectordelegate     };     zxing.options = options; } cameraresolution handlecameraresolutionselectordelegate(list<cameraresolution> availableresolutions) {     //don't know if ever null or empty     if (availableresolutions == null || availableresolutions.count < 1)         return new cameraresolution() { width = 800, height = 600 };      //debugging revealed last element in list     //expresses highest resolution. more thorough.     return availableresolutions[availableresolutions.count - 1]; } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -