Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Reading Barcodes from Your WP7 Device

0.00/5 (No votes)
26 Jan 2011 2  
Reading barcodes from your WP7 device

Barcode scanning doesn’t have loads of practical uses on a desktop (besides point-of-sale terminals), but on a mobile device, it’s a whole new ball game! Imagine a world where you can pick up an item, scan it with your phone and it gets delivered to your door… there are loads of scenarios where barcode scanning on your device makes sense! How difficult is it to do barcode scanning on a Windows Phone 7 device?

Introducing Windows Phone 7 Silverlight ZXing Barcode Scanning Library

“ZXing (pronounced "zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library originally implemented by Google in Java.”

To use this library is very simple, at the point where you want to scan the barcode, just call the following code:

WP7BarcodeManager.ScanBarcode((result) => 
{
    if (result.State == CaptureState.Success)
    {
        MessageBox.Show(result.BarcodeText);
    }
    else
    {
        MessageBox.Show(result.ErrorMessage);
    }
});

The result contains the details about the actual barcode and the state of the scanning process (if it succeeded or failed).

If you want the actual image of the barcode, do the following:

barcodeImage.Source = result.BarcodeImage;

P.S.: Don't forget to reference Silverlight_ZXing_Core.dll and WP7_Barcode_Library.dll.

And that’s it! Now you have full barcode support in your WP7 application, neat?

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here