question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xamarin.Forms Android Binding Issues

See original GitHub issue

I have just created a two page MVVM solution using Prism. The MainPage has a single button that navigates to a BarcodePage. The BarcodePage only contains the Barcode, but the back navigation is available in the status bar. The BarCodeValue is bound to a string on the view model.

When I navigate back from the BarcodePage to the MainPage in Android I get a SystemArgumentException: Found Empty Contents. When I hard code a value for BarCodeValue within the xaml everything works, and there is no problem in iOS.

I have the following NuGets installed: Xamarin.Forms v3.1.0.637273 ZXing.Net.Mobile v2.4.1 ZXing.Net.Mobile.Forms v2.4.1 Xamarin.Android.Support packages all v25.4.0.2 Prism.Dryloc.Forms v7.0.0.396

I believe the call stack for the error looks like this:

QRCodeWriter.encode (System.String contents, ZXing.BarcodeFormat format, System.Int32 width, System.Int32 height, System.Collections.Generic.IDictionary`2[TKey,TValue] hints)

MultiFormatWriter.encode (System.String contents, ZXing.BarcodeFormat format, System.Int32 width, System.Int32 height, System.Collections.Generic.IDictionary`2[TKey,TValue] hints)

BarcodeWriterGeneric.Encode (System.String contents)

BarcodeWriter`1[TOutput].Write (System.String contents)

ZXingBarcodeImageViewRenderer+<>c__DisplayClass5_0.<regenerate>b__0 ()

Thread+RunnableImplementor.Run ()

Any help would be greatly appreciated.

Thanks,

Andrew

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
gnoutcommented, Nov 22, 2018

@angelru Following is my implementation with a hidden entry field. I didn’t use the TextChange event as it was suggested by @abailie I just bound the ‘Text’ field of the entry (source) to the ‘BarcodeValue’ of the zxing (target)

<!-- Not Visible Entry -->
<Entry x:Name="EntryPhoneNumber" Text="{Binding MyBarCodeValue}" IsVisible="False"/>

<zx:ZXingBarcodeImageView BarcodeFormat="CODE_128"
	  BindingContext="{x:Reference Name=EntryPhoneNumber}"
	  BarcodeValue="{Binding Path=Text}">
	<zx:ZXingBarcodeImageView.BarcodeOptions>
		<zxcm:EncodingOptions Height="120" Width="1000" />
	</zx:ZXingBarcodeImageView.BarcodeOptions>
</zx:ZXingBarcodeImageView>

Thanks Dimitris

2reactions
Redthcommented, Mar 16, 2020

This is fixed in the 3.0 series.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Bindings - Xamarin
The first step to troubleshooting issues with binding a Xamarin.Android library is to enable diagnostic MSBuild output. After enabling the ...
Read more >
Xamarin Android Bindings Troubleshooting
One of the best ways to investigate a problematic Xamarin.Android Binding is to first ensure you have the proper tooling available:.
Read more >
Binding values not working on Xamarin Forms
I am building an application on Xamarin Forms using MVVM. The problem is that when I run the app, the data does not...
Read more >
Some Problems and Solutions When Creating Xamaring ...
Problem 1 - Wrong return type​​ Sometimes the generated code will have the wrong return type. This is often because of the difference...
Read more >
Creating a Xamarin Binding Library for iOS And Android ...
This article will be divided into two parts: Creating Binding Libraries in iOS and Android; Consuming the binding library in Xamarin Forms.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found