WalletBarcode.GetImageAsync 方法

定义

注意

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;
}

适用于

另请参阅