我尝试过为UWP应用程序安装QrCode.net nugget包,但是它为我写了一个错误:
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;是不存在的。
有人知道UWP应用程序的任何金块包可以帮助我创建和显示从字符串生成的QR代码吗?(UWP/C#)
发布于 2016-06-14 02:00:02
有人知道UWP应用程序的任何金块包可以帮助我创建和显示从字符串生成的QR代码吗?(UWP/C#)
由于您正在开发一个UWP应用程序,您可以使用Zxing.Net.Mobile包。安装此包后,要生成条形码,可以参考以下示例:
<Image x:Name="qrcodeImg" Stretch="None" />代码背后:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var write = new BarcodeWriter();
write.Format = ZXing.BarcodeFormat.QR_CODE;
var wb = write.Write("BarCode Content");
this.qrcodeImg.Source = wb;
}发布于 2017-11-06 18:59:39
这是如何使用MVVM模式(基于格蕾丝·冯的方法)
XAML
<Image Source="{Binding QRImage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>视图模型
// Property
public WriteableBitmap QRImage { get; set; }
// Function to call
private void SetQR()
{
var options = new QrCodeEncodingOptions()
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = 1000,
Height = 1000
};
BarcodeWriter writer = new BarcodeWriter();
writer.Format = BarcodeFormat.QR_CODE;
writer.Options = options;
QRImage= writer.Write(SelectedEvent.GetQrString());
}发布于 2020-10-04 20:39:40
2020年答案
另一种选择是使用QRCoder。来自github的一些示例设置。
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);https://stackoverflow.com/questions/37796416
复制相似问题