WalletBarcode.GetImageAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
不再支援 ApplicationModel.Wallet 命名空間,即將淘汰。 建議開發人員避免使用此命名空間。
建立並傳回條形碼的點陣圖影像資料流程 (,或傳回具現化) 期間使用的自訂影像。
public:
virtual IAsyncOperation<IRandomAccessStreamReference ^> ^ GetImageAsync() = GetImageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<IRandomAccessStreamReference> GetImageAsync();
/// [Windows.Foundation.Metadata.RemoteAsync]
/// [Windows.Foundation.Metadata.Deprecated("IWalletBarcode is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 917504, "Windows.Foundation.UniversalApiContract")]
IAsyncOperation<IRandomAccessStreamReference> GetImageAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<IRandomAccessStreamReference> GetImageAsync();
[Windows.Foundation.Metadata.RemoteAsync]
[Windows.Foundation.Metadata.Deprecated("IWalletBarcode is deprecated and might not work on all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 917504, "Windows.Foundation.UniversalApiContract")]
public IAsyncOperation<IRandomAccessStreamReference> GetImageAsync();
function getImageAsync()
Public Function GetImageAsync () As IAsyncOperation(Of IRandomAccessStreamReference)
傳回
非同步作業。 如果您使用 非同步程式設計,則成功完成時的結果類型為 IRandomAccessStreamReference 實例。 這可以指派為影像的來源, (一些額外的程式碼) 。
- 屬性
備註
如果使用採用自訂影像做為參數的 WalletBarcode 建構函式具現化 WalletBarcode 物件,則會在完成時傳回該自訂影像。 否則,系統會建立系統定義的條碼影像,然後傳回。
這個方法不會常傳回已備妥 UI 的影像物件,它會傳回定義點陣圖影像的資料流程。 若要實際設定映射,您可以使用類似以下的程式碼:
<Button Content="Generate barcode" Click="Button_Click"/>
<Image x:Name="barcodeImage"/>
private async void Button_Click(object sender, RoutedEventArgs e)
{
var walletBarcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "123123123123");
IRandomAccessStreamReference streamRef = await walletBarcode.GetImageAsync();
IRandomAccessStream stream = await streamRef.OpenReadAsync();
var bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(stream);
barcodeImage.Source = bitmapImage;
}