0
我正在Xamarin Forms中編寫一個QR碼應用程序,它在文本條目中輸入字符串並將其轉換爲QR碼。我希望QR碼在輸入或刪除文本輸入時動態更改,與本網站類似,我發現here。Xamarin - 替換TextChanged()上的QR碼事件
我相信這是可能的使用TextChangeEventArgs
但我不確定它是如何工作的。我在這裏錯過了什麼?
我的文字錄入
var myEntry = new Entry
{
Text = "Hello SO"
};
這裏是我的函數來創建一個新的條形碼時My Entry
改變(它沒有被任何東西叫尚)
void MyEntryChanged(Entry myEntry, TextChangedEventArgs e)
{
barcode = new ZXingBarcodeImageView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
AutomationId = "zxingBarcodeImageView",
};
barcode.BarcodeFormat = ZXing.BarcodeFormat.QR_CODE;
barcode.BarcodeOptions.Width = 300;
barcode.BarcodeOptions.Height = 300;
barcode.BarcodeOptions.Margin = 10;
barcode.BarcodeValue = myEntry.Text;
Content = barcode;
}
您可能需要使用Device.BeginInvokeOnMainThread更新UI時 – Jason