Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 2.23 KB

walletbarcode_getimageasync_1312294964.md

File metadata and controls

47 lines (35 loc) · 2.23 KB
-api-id -api-type
M:Windows.ApplicationModel.Wallet.WalletBarcode.GetImageAsync
winrt method

Windows.ApplicationModel.Wallet.WalletBarcode.GetImageAsync

-description

Caution

The ApplicationModel.Wallet namespace is no longer supported, and will soon be deprecated. Developers are encouraged to avoid using this namespace.

Creates and returns a bitmap image stream for the barcode (or returns the custom image used during instantiation).

-returns

An asynchronous operation. If you use Asynchronous programming, the result type on successful completion is an IRandomAccessStreamReference instance. This can be assigned as the source for an image (with some additional code).

-remarks

If the WalletBarcode object was instantiated using the WalletBarcode constructor that takes a custom image as a parameter, that custom image is returned on completion. Otherwise, an image of the system-defined barcode is created and then returned.

This method doesn't literally return an image object that's ready for UI, it returns a stream that defines a bitmap image. To actually set an image, you can use code similar to this:

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

-examples

-see-also

IRandomAccessStreamReference, Asynchronous programming