0
我正尝试在Windows应用商店应用中使用zxing条码库来生成条形码图像。 不显示图像。 以下哪项有问题?如何将WritableBitmap转换为BitmapImage
视图模型:
public BarcodeViewModel(INavigationService navigationservice, IDataService dataservice) : base(navigationservice, dataservice)
{
var bh = new BarcodeHelper();
BarcodeImage = new Image() {Source = bh.GetBarcode("123123")};
}
public Image BarcodeImage { get { return barcodeimage; } set { barcodeimage = value; NotifyOfPropertyChange(() => BarcodeImage); } }
查看:
<Image Source="{Binding BarcodeImage}"/>
条码类:
public WriteableBitmap GetBarcode(string barcodetext)
{
IBarcodeWriter writer = new BarcodeWriter { Format = BarcodeFormat.CODE_128 };
var result = writer.Write(barcodetext);
return result;
}