我试图安装QrCode.net金块包的UWP应用程序,但它对于我写的错误:如何在UWP应用程序中生成QR码?
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
不存在没有。
有谁知道任何UWP应用程序的块金包,可以帮助我创建并显示从字符串生成的QR码? (UWP/C#)
我试图安装QrCode.net金块包的UWP应用程序,但它对于我写的错误:如何在UWP应用程序中生成QR码?
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
不存在没有。
有谁知道任何UWP应用程序的块金包,可以帮助我创建并显示从字符串生成的QR码? (UWP/C#)
有没有人知道任何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;
}
这是你如何使用基于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());
}
我也尝试这种做法,但在最后一行我没有得到错误'无法隐式转换类型“字节[]”到“Windows.UI.Xaml.Media.ImageSource'' –
你可能应该把它'var wb =(写为ZXing.BarcodeWriterGeneric)。Write(jsonItem);' –
AbsoluteSith