Posted 30 September 2009 Tweet
Update 3/26/10: This also works with Windows Phone applications. 2D barcodes in Windows Phone applications post.
Thanks to the abundance of .NET class libraries that have been developed over nearly a decade of .NET software development, it’s amazingly easy to add powerful functionality to Silverlight applications by reusing existing code. Within a few hours, I was able to create two-dimensional barcodes in Silverlight – making me really want mobile support, web camera support, and printing (submit your Silverlight customer suggestions) for this functionality to be super useful.
My temporary obsession with 2D barcodes came about after I installed the awesome Starbucks Card Mobile app for my iPhone and drove by the Madison Park Starbucks on my way to Redmond, trying out their sweet mobile payment experience. The app worked great – I can only imagine how nice it will be once I can leave my physical Starbucks card at home!
Note: Image is provided by Starbucks, and not a real bar-code that’ll get you free coffee :-)
I’ve heard stories for years about how many countries worldwide are super-high tech, using QR two-dimensional barcodes everywhere, but this was my first experience as a regular consumer, other than seeing them on UPS shipping labels, expensive-looking gadgets in stores, and photos of interesting places:
There are so many versions of the QR code standard now that I settled on Version 2, which doesn’t hold as much data as some of the more complex versions – but the library iteself supports them all if you embed a few additional resource files into the assembly.
So what I set and did to get the bare minimum working:
Here’s the resulting control in use (click to experience the app):
It was a quick project, so now, I just need some Silverlight mobile – argh! There isn’t much application to a standard Silverlight app today, unless you want to use SaveFileDialog to store the image to the user’s homepage, or let them take a digital picture of the code. But hey, it was fun!
If you download the project, you’ll see that I purposely excluded a lot of the various QA code spec versions from the final assembly, to cut down its size, plus I commented out some of the encode capability – but overall it went together really quickly and is a solid library, for sure.
Download the zipped up solution with everything you need to experiment (Silverlight 3, C#, 1.1 MB)
Related note: Jeff Atwood posted a neat comparison of data over the years, back in July.
Jeff Wilcox is a Principal Software Engineer at Microsoft on the Azure team.
Jeff has been at Microsoft since 2005 and holds a Bachelor of Science from the University of Michigan. Jeff lives in downtown Seattle.