1

I'm looking at the sample for ZXing.net for Xamarin.Forms and it's using a code only approach to creating the barcode.

Since I'm using PRISM, with a backing ViewModel, I'm not entirely sure how to convert the following code into Xaml, so that I can place a label, or other text next to the object.

public class BarcodePage : ContentPage
{
    ZXingBarcodeImageView barcode;

    public BarcodePage ()
    {
        barcode = new ZXingBarcodeImageView {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand,
            AutomationId = "zxingBarcodeImageView",
        };
        barcode.BarcodeFormat = ZXing.BarcodeFormat.QR_CODE;
        barcode.BarcodeOptions.Width = 300;
        barcode.BarcodeOptions.Height = 300;
        barcode.BarcodeOptions.Margin = 10;
        barcode.BarcodeValue = "ZXing.Net.Mobile";

        Content = barcode;
    }
}

My question is, how do I design a page so that I can place the ImageView

TLDR
  • 1,198
  • 1
  • 12
  • 31

1 Answers1

2
xmlns:zx="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
xmlns:zxcm="clr-namespace:ZXing.Common;assembly=zxing.portable"

<zx:ZXingBarcodeImageView
                BarcodeFormat="QR_CODE"
                BarcodeValue="{Binding QrCode}"
                HorizontalOptions="FillAndExpand"
                VerticalOptions="FillAndExpand">
                <zx:ZXingBarcodeImageView.BarcodeOptions>
                    <zxcm:EncodingOptions Width="300" Height="300" />
                </zx:ZXingBarcodeImageView.BarcodeOptions>
            </zx:ZXingBarcodeImageView>
Jason
  • 86,222
  • 15
  • 131
  • 146