Good day everyone!

Please tell me why the generated barcode in the application is displayed in a narrow strip?

example

I add to the page through xaml

<ContentPage.Content> <StackLayout> <zxing:ZXingBarcodeImageView x:Name="Barcode" BarcodeFormat="CODE_39" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="300" HeightRequest="100" Margin="10" /> </StackLayout> </ContentPage.Content> 

Barcode value set in the code

 Barcode.BarcodeValue = "10348180"; 

I tried many options, but without much success. For some reason it does not work through the code, the barcode is not displayed on the page. Prompt if encountered. I will be glad to any advice. Thank!

  • Try setting width and height in ZXingBarcodeImageView.BarcodeOptions - Emigrant
  • I tried. Added: Barcode.BarcodeOptions.Height = 100; Barcode.BarcodeOptions.Width = 300; . From the markup, respectively, removed. On the page - empty :( Why, why ...? - Andrey Nov.

1 answer 1

Finding a solution to my question turned into a sudden success! I tried an example where QR-code was generated, and it started working right away. Next, I tried to change the format of the barcode to the one I needed - and the barcode was normally displayed on the page!

Did through the code:

 public MainPage() { InitializeComponent(); KOD = "103865998"; var qrCode = new ZXingBarcodeImageView { BarcodeFormat = BarcodeFormat.CODE_39, BarcodeOptions = new QrCodeEncodingOptions { Height = 100, Width = 350 }, BarcodeValue = KOD, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; StackLayout stack = new StackLayout() { Children = { qrCode } }; this.Content = stack; } 

Like this.