I am trying to display a barcode in my app using binding in my xaml. My question is how can I convert the barcode to be used in the xaml Image source. I have tried using a byte property but I get this compile error : "Cannot implicitly convert Zxing barcode image view to 'byte'". Any guidance on how to achieve this will be appreciate, thanks.
Cards.cs
public class Cards
{
public int CustomerID { get; set; }
public int DiscountLevelID { get; set; }
public string DiscountLevel { get; set; }
public double DiscountLevelAmount { get; set; }
public bool StoreCustomerGiftCard { get; set; }
public bool StoreCustomerLoyalty { get; set; }
public int LoyaltyLevelID { get; set; }
public string LoyaltyLevel { get; set; }
public double LoyaltyLevelRatio { get; set; }
public double Balance { get; set; }
public int StoreNumber { get; set; }
public string CardNumber { get; set; }
public bool IsError { get; set; }
public object ErrorMessage { get; set; }
public string CompanyName { get; set; }
public string CustomerLogo { get; set; }
public byte BarCode { get; set; }
}
Cards.xaml.cs
ZXingBarcodeImageView barcode;
barcode = new ZXingBarcodeImageView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand };
barcode.BarcodeFormat = ZXing.BarcodeFormat.QR_CODE;
barcode.BarcodeOptions.Width = 300;
barcode.BarcodeOptions.Height = 300;
barcode.BarcodeOptions.Margin = 10;
barcode.BarcodeValue = i.CardNumber;
i.BarCode = barcode;
Cards.xaml
<Image Source="{Binding BarCode}" />