I am having an issue that is hopefully rather simple. I am creating a simple xamarin forms app that uses zxing to scan a barcode and currently I just want it to display that in the entry field on the form but the binding doesn't work and neither does the commented code that just sets the value from the code behind. In fact for some reason in this simple project directly accessing the form items from the code behind just freezes the app when debugging. Hoping someone can point out some simple issue in the code causing this. Thanks.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 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"
x:Class="Inventory.MainPage">
<ContentPage.Content>
<StackLayout>
<Grid x:Name="gridScanner">
<zxing:ZXingScannerView x:Name="zxing" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" OnScanResult="ZXingScannerView_OnScanResult" />
<zxing:ZXingDefaultOverlay x:Name="overlay" TopText="" BottomText="Barcode will be scanned automatically" ShowFlashButton="False" />
</Grid>
<StackLayout>
<Label x:Name="lblSku" Text="SKU" FontAttributes="Bold" FontSize="Title"/>
<Entry x:Name="txtSku" Placeholder="SKU" ReturnType="Next" />
</StackLayout>
</StackLayout>
</ContentPage.Content>
public MainPage()
{
InitializeComponent();
_currentItem = new ScanItem();
txtSku.BindingContext = _currentItem.SKU;
txtSku.SetBinding(Entry.TextProperty, "Value");
zxing.IsScanning = true;
}
public void ZXingScannerView_OnScanResult(Result result)
{
_currentItem.SKU = result.Text;
//txtSku.Text = result.Text;
}