Silverlight Hack

Silverlight & related .NET technologies

About Me

Welcome to Silverlighthack.com.  This is a site where you can find many articles on Silverlight, Windows Phone 7 and .NET related technologies.  

My name is Bart Czernicki.  I have been working with computers since 1988 and have over 12 professional years in the IT field focusing on architecture, technology strategy and product management.  I currently work as a Sr. Software Architect at a large software development company.

Below is the cover of my new book that shows how Silverlight's unique RIA features can be applied to create next-generation business intelligence (BI 2.0) applications.

Silverlight 4 Business Intelligence Soft 

Contact: [email protected]

View Bart Czernicki's profile on LinkedIn

NONE of the comments or opinions expressed here should be considered ofmy past or current employer(s).  The code provided is as-is without anyguarantees or warranties.

Calendar

<<  November 2010  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar

RecentComments

Comment RSS

BlogRoll

  • RSS feed for Allan Muller's Silverlight BlogAllan Muller's Silverli...
Download OPML file OPML

Creating a ASP.NET MVC HTML Helper for Silverlight

Abstract:  This article covers how to  create a custom ASP.NET MVC HTML Helper that will render the required HTML to host a Silverlight application (XAP file). Some knowledge of ASP.NET MVC is required.

Over the last few weeks I have started investing some time in learning ASP.NET MVC (specifically ASP.NET MVC 2).  This has nothing with the ongoing "Silverlight is dead" debate and I actually started a deep dive into the technology back in August 2010.  I think that ASP.NET MVC is very important for Silverlight developers to learn (more on this in another blog post), because of its obvious positioning in Microsoft's HTML5 tooling investments (more on that in MIX 2011).

Intro to HTML Helpers

HTML Helpers have the following qualities:

  • Usually implemented via extension methods
  • Usually implemented part of a static class
  • In .NET 4.0/C# 4.0 utilize optional parameters to minimize the initialization signature
  • Used inline with HTML in ASP.NET MVC Views to create dynamic content, while minimizing the code written and maintained
Basically an HTML helper is a extension method that takes some parameters and renders HTML.  In ASP.NET MVC you have complete control over the rendering of the HTML in your Views.  If you are an ASP.NET developer you can think of it as having the ability to dictate the exact HTML/Javascript that gets surfaced when you drag over any ASP.NET server control.  For example, if you drag over an ASP.NET button server control, ASP.NET handles how that control is rendered on the page.  Of course in ASP.NET you could override the rendering from the server, however it was a major pain.
 
HTML Helpers in ASP.NET MVC are there to minimize how much code you need to write.  For example, instead of having to write 100 lines of HTML every time there is an input form.  You could create an HTML Helper that does this for you.  This minimizes the code, improves maintenance of your code and abstracts that component into its own SRP (single responsibility principle) method.
 
ASP.NET MVC versions 1 through 3 include a ton of HTML Helpers.  These helpers include basic methods for rendering simple HTML like a text box to more complex helpers.  If you download the ASP.NET MVC 3 source code, you will see a lot of very complex HTML Helpers.  These HTML helpers can render complex HTML with interactive HTML.  For example, my companion site (http://www.silverlightbusinessintelligence.com) for my Silverlight business intelligence book utilizes the Twitter HTML helper that renders my tweets in a nice interactive HTML component with JavaScript that makes the appropriate web service requests.  Some of the advanced HTML helpers include: Facebook, Twitter, video etc.  The beauty of this is that in order to utilize this component I just had to reference it using one line of code.
 
 
Creating a Silverlight HTML Helper
 
In order to host a Silverlight application (XAP file) you need to create the following HTML at a minimum  (if you want error handling you will need additional JavaScript):

 
In order to create an ASP.NET MVC HTML Helper to host Silverlight we simply need to create a extension method that renders the HTML shown above.  When creating an HTML helper for an HTML component, you should analyze which parameters would be helpful to make the HTML more dynamic.  For example, for the Silverlight helper we could potentially have the following parameters:
  • URI location of the Silverlight XAP file
  • Silverlight minimum runtime version (minRuntimeVersion parameter)
  • Width and height dimensions of the Silverlight div tag
  • Silverlight application initialization parameters
  • Provide a dynamic name for the onError JavaScript method
In addition to the flexibility, the HTML Helper should provide a simple method signature.  For example, if I just want to provide the location of the Silverlight XAP file; why would I want to pass in all of these additional method parameters.  This is ideal for using the new .NET 4.0/C# 4.0 optional parameter syntax.
 
The rest of the HTML Helper is very simple; combining the method parameters with the static HTML div tag and rendering the content.  You are essentially building a .NET string that contains HTML content.   This can be done several ways (as shown below).  I used the string.Format method (because it uses StringBuilder for performance behind the scenes) and optionally for a cleaner "non-string" method you can use LINQ to XML to create the HTML string all in C#.
 
Creating the HTML using string.Format 

 
Creating the HTML using LINQ to XML

The final piece of the HTML Helper is to return an HTMLString object (which overrides some string method implementations).
 
Using the Silverlight HTML Helper
 
Using the Silverlight HTML Helper in an ASP.NET MVC View is incredibly simple.  Using the C# inline code in the view, all that needs to happen is to execute the HTML Helper method.  In the example below, I pass in the URI of the Silverlight XAP file and two optional height & width parameters.
 
If you are not familiar with C# optional parameters, notice the syntax below.  "objectContainerWidth: ...".  We can specify the optional parameter we want to pass into the method and the value.  If the HTML Helper had 20 parameters the syntax of this method would be very bloated.  However, optional parameters make the syntax very terse. 
 
 
 
Where and Why Would you want to do this?
 
There are a couple great uses of this Silverlight HTML Helper.  The first use is to simply host Silverlight applications in ASP.NET MVC.  If you create a "new Silverlight Project" and host it in a ASP.NET MVC project, you don't get a good hosting environment.  What actually happens is that you get an aspx page that is completely outside ASP.NET MVC views. 
 
 
Another great use of this Silverlight HTML Helper is to create dynamic web sites that include a lot of Silverlight content.  My companion site for my Silverlight BI books had a requirement of this.  I have over 60 Silverlight demos I needed to host on the web with different Silverlight versions.  If you navigate to http://silverlightbusinessintelligence.com/Demos you can see the Silverlight HTML helper in action.  Using the Silverlight HTML Helper I can pull all of the values from a SQL Server table and dynamically create the views for each respective demo.
 
Sample of some of my Silverlight HTML Helper Parameters stored in a database table 
 
 
Source Code
Attached is the cs file for the Silverlight HTML Helper.  Feel free to extend the HTML Helper as you wish.  I have omitted error checking and rendering the additional JavaScript files.  This could be added simply.   I did this on purpose, because right now ASP.NET MVC does not allow you to render JavaScript in the appropriate places.  You could create two separate HTML Helpers (one for the Silverlight XAP file and one for the JavaScript).  This would allow you to place the Silverlight JavaScript file with all your other js files on the web page.
 
Posted: Nov 16 2010, 08:52 by Bart Czernicki | Comments (3) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: ASP.NET MVC | Silverlight
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Windows Phone 7 Development Tip: Use Concurrent Programming Techniques

Windows Phone 7 devices are out in the wild; now we can finally test if those emulator performance enhancements truly work.  There is A LOT of misinformation out there about the hardware of the Windows Phone 7 devices.  You can see that the Windows Phone 7 hardware utilizes the 1st generation SnapDragonprocessor which includes a single CPU.  However, the single physical CPU is able to effectively manage multiple threads concurrently.

Today I had a chance to deploy a Windows Phone 7 sample from my book to a physical Windows Phone 7 device and I was pleasantly surprised that the multithreading performance in the emulator is reflected on the physical phone device.  The sample I wrote was a simple slider that is tied to a fake activity of 150ms of CPU "work".  On the physical device the second slider (shown below) completely locks up the entire device and the application becomes unusable.  The third slider is very responsive, because it uses a secondary thread to manage the work.

 

I included the source code here.  If you are interested in how this optimization works, refer to Chapter 10 (Concurrent Programming) and Chapter 12 (Mobile Intelligence) of my book.  I have blogged numerous times about concurrent programming in Silverlight herehere and here.  Even in my current book, I devoted an entire chapter to concurrent programming in Silverlight 4 including an example for the Windows Phone 7.  Since Windows Phone 7 apps run Silverlight 3 (plus a little Silverlight 4 with some threading changes) all these multithreading techniques I have written about (in my book and online) will apply.

Posted: Nov 09 2010, 18:33 by Bart Czernicki | Comments (5) RSS comment feed |
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Silverlight Framework - All Historical Tool Releases and What is New

Abstract:  This article looks at all the major historical Silverlight and related technology releases.  Plus I look at what was recently announced at the PDC 2010 and evaluate Silverlight support for new technologies.

Much has been said about Silverlight being deprecated, repurposed or even "dead" by the media and fellow bloggers.  In this article I wanted to look at a timeline of all the releases Microsoft and others have made that relate to Silverlight.  I also wanted to take a look at some of the recent and upcoming releases for the Silverlight framework.

Timeline History of Silverlight

Below is a timeline of all the Silverlight related releases.  I included a bullet list with details.  Click here for a large to see image.

Note: Only the major releases are highlighted below

  • 09/2007 - Silverlight 1.0
  • 10/2008 - Silverlight 2.0, Expression Blend 2 SP1, Silverlight Control Toolkit
  • 03/2009 - Silverlight Control Toolkit (200903)
  • 07/2009 - Silverlight 3.0, Expression Blend 3 + Sketchflow, Silverlight Control Toolkit (200907)
  • 11/2009 - Silverlight Control Toolkit (200911)
  • 12/2009 - Bing Maps Silverlight Control
  • 01/2010 - Microsoft Silverlight Media Framework 1.x
  • 04/2010 - Silverlight 4.0, Silverlight 4 Toolkit, WCF RIA Services 1.0, Visual Studio 2010 Support, F# Support, MEF Support, WCF Data Services, Silverlight Unit Test Framework
  • 05/2010 - Prism 2.2 for Silverlight 4
  • 06/2010 - SharePoint 2010 (Native web part support & Silverlight client for SP data), Silverlight Smooth Streaming Client
  • 07/2010 - Microsoft Silverlight Media Framework 2.x
  • 06/2010 - Expression Blend 4 RTM, Silverlight PivotViewer 1.x, Microsoft Silverlight Analytics Framework 1.x
  • 09/2010 - Windows Phone 7 Silverlight SDK, Blend for WP7, WP7 Control Toolkit

So whats the point?  As you can see the investments in Silverlight have been accelerating rapidly.  It would be a complete 180 for Microsoft to deprecate or ditch this technology.  Future will tell if Microsoft will support these technologies.

What is New upcoming with Silverlight? (PDC 2010 stuff you probably missed)

There was NO Silverlight at the PDC.  Wrong!  A lot of frameworks, tooling outside the "major" Silverlight releases really fly under the radar.  Below I noted some things that are new and some of the releases that Microsoft has updated in the last month or so for Silverlight.

  • WCF RIA Services SP1 Beta: 
  • WCF RIA Services (October 2010 Toolkit for RIA Services SP1): 
    • New features include: Azure Table Storage Support, code generation, business templates etc.
    • http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a23325ef-7b1f-4c92-9fd5-ffee48f7c7bc
  • Visual Studio Async CTP
    • Next-gen preview of C#/VB.NET features that allow easier asynchronous programming techniques.  INCLUDES a Silverlight library that support Task based declerative parallelism (very cool stuff)
    • Note: The default example is written for......Silverlight 4 :)
      • http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=asyncdocs&DownloadId=14261
    • http://msdn.microsoft.com/en-us/vstudio/async.aspx
  • Announced that WPF will be able to host Silverlight content natively
    • This is a pretty neat ability.  Imagine writing a Silverlight app and being able to host it on the web, web parts and in WPF
  • IIS Media Services 4.0 Released
    • Extends the IIS 7.x story as a media delivery platform.  Includes new smooth streaming/DVR features.
    • http://blogs.iis.net/chriskno/archive/2010/11/01/iis-media-services-4-0-released.aspx 
Honorable mention goes to the WCF Web APIs.  How is this related to Silverlight?  Well, if you listened to Glenn Block's PDC presentation he mentioned that Microsoft is embracing the REST standard over the WS* (SOAP) standards.  Silverlight did not support WS* services.  This is nice, because now Silverlight can easily be utilized in SOA initiatives based on REST.
Is Microsoft Supporting the other Silverlight related frameworks?
You be the judge....some recent releases
  • Silverlight Bing Maps Control: 06/2010 (1.01 release)
  • Silverlight PivotViewer Control: 09/08/2010 (1.01 release)
  • Silverlight Media Framework: 10/04/2010 (2.2 release)
  • Microsoft Silverlight Analytics Framework: 10/09/2010 (1.47 release)
  • Prism v4: 10/14/2010 (Drop 10)
Summary 
As you can see there were some Silverlight related announcements/releases that where overshadowed by the whole Silverlight drama that occurred.  I hope you guys can use this to show other peers or senior management that Microsoft's investment in Silverlight has been very strong.  In addition, Microsoft has a lot of new things coming out that amplify their investment in Silverlight. I would say that Silverlight is hardly dead and the amount of Silverlight related technologies is only accelerating! :)
Posted: Nov 02 2010, 11:05 by Bart Czernicki | Comments (5) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

PDC 2010: Top 5 Reasons Why Microsoft Completely Screwed up their web strategy with HTML 5

Update 11/1/2010:  Officual update from Bob Muglia: http://team.silverlight.net/announcement/pdc-and-silverlight/

This is an article in response to Microsoft's new web strategy that was announced this week at the PDC 2010.  In a nutshell,  Microsoft is fully embracing HTML 5 and re-purposing Silverlight for rich client development (Windows Phone 7).

Here are my 5 reasons why Microsoft really messed this one up (coming from a perspective of timing, tooling and corporate means of making money):

  1. HTML 5 is not ready yet...and don't know when it will be
  2. Internet Explorer 6-8 problem
  3. No Microsoft HTML 5 Tooling announced 
  4. The CIO/CTO effect
  5. Silverlight is in limbo...wait til MIX 2011 to find out more

HTML 5 is not ready yet...and don't know when it will be

HTML 5 has become an abstract term already before being released.  When someone tells you they implemented a site in HTML 5; what does that mean?  Are they just using some HTML 5 tags like Canvas?  Have they implemented CSS 3, SVG, Web Workers, WebGL?  HTML 5 has several related technologies that are being developed in parallel or as part of the HTML 5 specification.  No current browser supports the entire gamut of "HTML 5 and related technologies".

When is HTML 5 being released?  HTML 5 is not a true language from a purist perspective.  It is a set of standards that are accepted and implemented in web browsers.  Here in lies the problem...even if the full HTML 5 spec is done; then all the browsers need to implement it.  Finally, all the browsers the billions of people have installed need to be replaced with "full HTML 5 compliant browsers"

Example 

I wanted to highlight Google's YouTube as an example.  Google is very pervasive with HTML 5 and Ian H. runs the HTML 5 spec essentially.  Look at their youtube site and HTML 5 is there, but NOT the default.  If HTML 5 was so ready, then why need Flash?  Well simply a majority of the browsers don't support it....even Google's current browser version does not.  Their WebM standard uses VP8 codec, which is the open source one that everyone fought over in the "HTML 5 codec wars".  If you are on IE 6-8 you need to INSTALL Google Frame...lol.  Imagine you are an architect, CIO....are you going to write an app in all of HTML 5 now if you need RIA functionality?

Internet Explorer 6-8 problem

Internet Explorer 9 will be Microsoft's first browser to support HTML 5.  However, it is in beta and probably won't be released until April 2011.  So, did Microsoft just dump Silverlight for a platform they don't support?  YES!  Even if Internet Explorer 9 was RTM'ed today, over 63% of the world is using Internet Explorer which is NOT HTML 5 compliant!  It will literally take years for everyone to get Internet Explorer 9 widely supported.  This is not even mentioning older versions of Chrome, Opera or Firefox.  I would bet that about 70% of the CURRENT browsers do not support HTML 5 even partially.

No Microsoft HTML 5 Tooling Announced

So what are Microsoft's great new tools to create HTML 5 web sites?  Uhhhh.....I don't know.  Microsoft was very mum on this.  One would think that when you are shifting to HTML 5 you would show something a little more than just Internet Explorer 9 Beta.  However, that is exactly what Microsoft did:

  • no new Expression Web shown
  • no export from Silverlight to HTML 5 (like Adobe has)
  • no HTML 5 helpers for ASP.NET MVC announced 

In my opinion, this is completely ridiculous.  I know no one "owns" HTML 5.  However, don't you want developers (that buy your software and OSes) to develop using YOUR software?  What is to stop an Adobe Flash or Silverlight developer dropping Windows and Visual Studio 2010 and going on a Mac with open source HTML 5 tools?

The CIO/CTO Effect

Every headline today about the shift in strategy has been HTML 5 wins and Silverlight loses.  Imagine what a CIO/CTO will think, when they get their tech info from these "high level technology summary" web sites or periodicals.

It doesn't take a genius to figure out the clear message here in the headlines (even without reading the article).  So I would bet if you were deciding on which technology to work on that upcoming project...this shift in strategy might scare senior management away from Silverlight.

Silverlight is in limbo...wait til MIX 2011

So what is going on with Silverlight?  When is the next release?  Is Microsoft discontinuing Silverlight?

If you have a vested interest in Silverlight, you have to wait 5 months until MIX 2011 (Microsoft's web conference) to find out what is going to happen next.  For someone who has invested in this technology, I find it insulting.  The problem is that you don't know anything clear.  This is very akin to Wall Street..."the market hates not knowing";  they want to know where to invest based on the news.  If you don't know where Silverlight is going; how seriously are you going to champion or invest in the technology?

 

What would you have done?

I listed all the reasons, why I think Microsoft screwed up the web strategy this week.  This is what I would have done: 

  • DELAY the shift in strategy to "re-purpose" Silverlight and declare HTML 5 the winner UNTIL Microsoft had the tooling, Internet Explorer RTM'ed
    • (credit to Paul Litwin for this one)  How about waiting until Windows Phone 7 matures.  Don't you need as many devs creating Windows Phone 7 apps using Silverlight?  If people leave Silverlight, then this will drop the pool of devs creating WP7 apps.
  • Be very explicit in Silverlight's role on the web, cloud and the client
  • Either commit to or scrap Silverlight's future (don't leave it in limbo)
  • Show how Microsoft is going to revolutionize HTML 5.  Don't be a Steve Jobs sheep and jump on HTML 5.
 
In summary, Microsoft really fumbled the web strategy this week.  What amplifies the fumbling is that they did this AT THE PDC (Professional Developer's Conference).  Doing this to developers at "their" conference and not explaining Silverlight's future is totally unacceptable.  I think senior management is to blame and wanted to have a "direct message about the web".  This should have been done when Microsoft had HTML 5 "ready to go" with tooling and IE 9 was released. Microsoft has a great platform in Silverlight that can compliment the web.  However, they are shifting their strategy to a platform that is not ready, don't know when it will become "released" nor do they have their own tools to develop for....HUGE MISTAKE. 
Posted: Oct 29 2010, 16:10 by Bart Czernicki | Comments (52) RSS comment feed |
  • Currently 4.875/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: HTML 5 | Silverlight
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Windows Phone 7 RTM charting using the Silverlight Control Toolkit

Abstract: This article will show you the steps to surface charting data visualizations using the Silverlight Control Toolkit on the Windows Phone 7.  I will also cover the reasoning behind these steps and the gotchas/errors you may encounter.  Source code is included with a sample Windows Phone 7 project.

Windows Phone 7 RTM tools have been released a few weeks ago.  Many developers are starting to develop their new apps and getting them ready for the Windows Marketplace.   If you are a seasoned Silverlight develper, you probably want to leverage existing Silverlight frameworks or toolkits (i.e., MVVM, networking, charting, custom controls etc.) in your Windows Phone 7 application.  If you have looked for a charting solution, you probably came across several articles that "claim" to show you how to easily surface charting on the Windows Phone 7.  Most examples are out of date (because the Windows Phone 7 bits changed so much) and some of them simply have misinformation (i.e., I read one article and the author doesn't even know what assembly he is using :))

Background Info

As you may know the Windows Phone 7 RTM includes a Silverlight runtime.  Scott Guthrie announced during the MIX 2010 conference that "this isn't Silverlight Lite.....this is Silverlight" and I wrote an article that shows this is not the case.  The Windows Phone 7 RTM runtime is based off of Silverlight 3 RTM and includes some additional things from Silverlight 4 and some custom inner workings for the Windows Phone 7 (i.e. UI thread and Composite thread).  Basically, what this means is that most Silverlight 2 and Silverlight 3 code "should just compile and work" on the Windows Phone 7.  If you have written Silverlight 4 code that takes advantage of new features it will simply not work in the Windows Phone 7 Silverlight runtimes (although this will probably change and both Silverlight runtimes will converge in functionality).

There is a lot of misinformation out there (even from Microsoft) that the Silverlight 4 Control Toolkit is compatible with the Windows Phone 7 and it's not.

Steps to Get Silverlight Control Toolkit Data Visualizations to Work in Windows Phone 7

  1. Download the November 2009 Silverlight 3 Control Toolkit (http://silverlight.codeplex.com/releases/view/36060#DownloadId=93512)
    • The April 2010 Silverlight Control Toolkit dropped support for Silverlight 3.  The November 2009 release is the latest stable release for Silverlight 3.
  2. Create a new Windows Phone 7 project
  3. Add a reference to the System.Windows.Controls.DataVisualization.Toolkit.dll
    • Ensure the DLL comes from the Silverlight 3 toolkit (November 2009) NOT the Silverlight 4 toolkit
    • The default location is: C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Toolkit\Nov09\Bin\System.Windows.Controls.DataVisualization.Toolkit.dll
  4. Add a reference to the System.Windows.Controls.dll
    • Ensure the DLL comes from the Silverlight 3 client SDK
    • The default location is: C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Control.dll
  5. Drag over chart and series from Asset library; start using the chart data visualizations normally
    • I have tested pie, line and bar charts and all seem to work nicely

Example

In the figure below, you can see the Windows Phone 7 emulator running a Pie Chart data visualization with a slider.  I decided to style the Pie Chart, bind it to sample data, double bind one of the elements to a slider to test the rendering engine of the Windows Phone 7.  I am happy to say that everything looks like it is working on the Windows Phone 7 as expected.  Source code is located here.

What Will Happen If you use the Silverlight 4 Toolkit Assemblies?

In short, you will see everything work great in Blend 4 or Visual Studio designer.  However, as soon as you deploy the project to the emulator the project will launch and promptly close throwing an exception of:"Invalid attribute value charting:DisplayAxis for property TargetType".  I am guessing there is a Silverlight 4 feature being used (i.e. element binding) that may be causing the error in the Windows Phone 7.  If you receive this error, then you need to reference the Silverlight 3 version of the System.Windows.Controls.DataVisualization.Toolkit.dll

 

What Will Happen If you forget to add the System.Windows.Controls.dll assembly?

The Blend designer and Visual Studio designer will both work.  However, if you deploy the project to the Windows Phone 7 it will promptly error out by throwing an exception.  The exception is going to be the generic XAML error "AGE_E_PARSER_BAD_TYPE line...".  The reason this error happens is that the charting controls need artifacts that are located in that assembly that are missing from the Windows Phone 7 Silverlight controls.  Luckily, since the Windows Phone 7 runs Silverlight 3 (plus some enhancements) we can use the Silverlight 3 assemblies.  Please note that this will likely change when the Windows Phone 7 and full Silverlight runtimes converge in functionality. 

 

Summary

Until Microsoft converges the Silverlight runtime functionality with the appropriate Silverlight Control Toolkits, you will have to be aware of the supported functionality in each version.  In order to surface charting data visualizations in the Windows Phone 7, use the November 2009 Silverlight 3 Toolkit and reference the System.Windows.Control.dll from the Silverlight 3 SDK. 

Source Code: WindowsPhone7ChartingExample.zip (1.32 mb)

Posted: Oct 08 2010, 10:12 by Bart Czernicki | Comments (14) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Technical Book Sales Insight Through Real-Time Amazon Rankings Analytics

As a published author, I have a product available to the masses.  The obvious question that comes to mind after the product is released is "How well is my product selling?".  If you are a technical author, you receive a statement every quarter for the previous three quarters.  For example, my publisher which is Apress sent me a summary at the end of March 2010 for Q4 2009.  Essentially, you are getting data that is 3-6 months behind.

Average technical books usually sell somewhere in the range of 2,000-3,000 copies during their lifetime.  Really popular books can sell up to 6,000-8,000 copies.  Furthermore, these books tend to have a short shelf life of about 1-2 years where 90%+ of the sales come from.  This is especially true for a technology like Silverlight which is on a 9 month cadence.  Technical books also have limited marketing budgets.  Even authors like Pretzold don't have commercials on TV for their books :)  This makes it very important to make sure you can get as many sales as possible quickly before your book becomes "old news".  Waiting three months for a quaterly statement can dramatically limit your recourse to improve sales.  What can a technical author do?

Using Amazon's Domination to Your Advantage

Amazon is one of the world's largest online retailers specializing in many items especially books.  Since a very large percentage of sales go through Amazon, we take advantage of this.  This is especially true for technical resources.  If you are a technical author, chances are, your book is not being carried by a brick and mortar bookstore (unless it is ultra popular or covers a broad topic).  Obviously, this is not the same for authors of fiction books like Dan Brown (DaVinci Code fame).  After talking to my publisher, the estimate is that about 50%-75% of the book sales will come from Amazon.  Using this information, I can start to get a good idea of how my sales are doing now.  This topic is a lot more interesting to me because I wrote a book about Business Intelligence and Silverlight.  In Business Intelligence software, you want to have a tool that can provide you insight that you can make wise decisions from quickly.

Amazon Sales Rankings

Amazon receives tremendous sales volume.  Amazon publicly provides some sales information on sales on its site.  While you will never get detailed information as how many books have been sold over time, Amazon does provide a sales rank system.  Amazon's formula is secret.  However, you will find a lot of guesstimates on the web from people who have tried to reverse engineer it.

The Amazon Sales rankings are a ranking (lower is better) over a rolling time frame (a year?).  The sales rankings are updated hourly on Amazon's site and displayed on the book's Product Details section.  Notice the screen shot below and the description explicitly say amazon.com not Amazon.  The reason is that Amazon has multiple domains that tailor the site specific to the locale.  For example, other popular Amazon sites include: Amazon.ca (Canada), Amazon.jp (Japan), Amazon.de (Germany), Amazon.fr (France).  Each of these domains tracks sales seperately.

Amazon.com Sales Rank of my book for April 8th 2010

 
Every time you sell a book, your ranking drops lower (which is good).  If you don't sell a book, your ranking starts to creep up every hour.  If you don't sell a book in several months, you will quickly be looking at a sales rank of millions.
 
Knowing this information, we can manually track our sales and see how well we are doing.  Luckily, Amazon includes public APIs that can be used to track this as well.
 

Amazon Sales Rankings - What they Mean

What does a ranking of 1,000 or 100,000 mean?  How many books does that translate to per month?  Based on the data I have seen, this is how I grouped the sales numbers into sales ranking buckets.  (Note: The focus of this article is technical books.  Therefore, I am skipping buckets like Top 50).  The rankings are based on a logarithmic scale.  So as you go into further lower ranking, you are selling exponentially more than rankings that are higher.

Logarithmic scale of book sales (source: www.fornerbooks.com).  Data is from 2007.  

  • Consistent ranking 200 - 1,000: You are selling extremely well. Well over 1,000 per month on Amazon domains!  Example:  The Design of Design: Essays from a Computer Scientist.
  • Consistent ranking 1,001 - 10,000:  Your book is doing very very well.  You are selling between 400-900 per month on Amazon domains.  Example: Pro Silverlight 3 in C# or C# 4.0 In a NutShell
  • Consistent ranking 10,001 - 50,000:  Your book is selling well.  You are selling between 80-350 per month on Amazon domains.  Example: (my book) Next-Generation Business Intelligence Software with Silverlight 3 or Programming WCF Services
  • Consistent ranking 50,0001 - 125,000:  Your book is doing OK.  You are selling between 40-70 per month on Amazon domains.  Example: ASP.NET MVC In Action
  • Consistent ranking 125,001 - 300,000:  Your book is doing below average.  You are selling between 10-35 books on Amazon domains.
  • Consistent ranking 500,000 - 1,250,000:  You are selling a very small amount of books.  You are selling between 1 - 9 books on Amazon domains.
  • Consistent ranking > 1,250,000:  You are not selling anything at all. Maybe 1-2 books per month.
When I was researching this for the last several months, I found most sites to be wrong or have outdated information.  For example, some sites only report sales from Amazon.com.  While the core Amazon.com has the bulk of the sales, a very large percentage of sales come from international domains; in some cases, almost half the sales!  A lot of sites that claim to have deciphered the Amazon Sales Rank formula paint only half the picture.
 

NovelRank.com automates tracking Amazon sales data

Novelrank.com is a great site that is provided for FREE from Mario Lurig.  Mario essentially took advantage of the fact that Amazon updates their site hourly and they provide APIs.  He was able to figure out a formula that accurately can extrapolate sales information from the sales rankings.  Its a fantastic feature provided for FREE.
 
The API provided can track sales on the 6 most popular Amazon domains and provide data visualizations for analysis.  You can also create your own page to compare other book's data.
 
NovelRank analysis page of my book's sales for the first week of April 2010.  Click here to see the tool in action live.
 
 

You can even export the data into Excel to use, place a sales widget on your portal, filter the graphs etc.  The site also includes many valuable insights about Amazon sales information.  Using this tool, I was able to come up with my own Amazon sales figures you see above.  I think these paint a much more accurate picture that you are going to find. After the month's data is complete, if you multiply the number by 1.5-2.0, that is a good estimate of the amount of sales a technical book will do in a given month.
 
Note: The Amazon sales rank and APIs are public information.  While I guess it is considered "snooping" on someone's data, I don't think it violates any privacy issues.  You can add any book that is on Amazon's domains for tracking and analysis.
 

Insight Gained from NovelRank Analytics

Improving Book Sales 

The only way you are going to improve sales is through marketing yourself and your product (which is your book).  Using a real-time analytics tool like NovelRank allows you to adjust your book's marketing efforts appropriately.  Here is some insight that I gained:

  • At the time the MIX 2010 conference was held, my book was consitently in the 1,001-10,000 range.  Technical book sales go up during related conferences.
  • Make sure you have a blog.  Write about content related to your book.  Advertise your book prominantely on the site.
  • Create a companion site for the book.  For example, for my book, I created www.silverlightbusinessintelligence.com.  This allows me to target readers that don't have Visual Studio installed or don't feel like compiling the demos.
  • When posting on forums, add your book info to your signature.  For example, I am active on the Silverlight forums and have a link to my book's Amazon listing.
  • Do speaking engagements if you can.  If you are a good speaker and have something interesting to say, it is a good idea to advertise yourself.
As you do these items, you should see spikes in books sales.
 

Thinking about writing a book in....

If you are thinking about writing a technical book to make additional income, you can improve the financial results by using NovelRank.

  • General book topics usually do better.  For example, a book on C#, Intro to Silverlight or WCF will do better than a highly specific book or a niche technology area.  For example, my book focuses on Business Intelligence and Silverlight.  This obviously has a much smaller audience than just a vanilla C# syntax book.  In my case, this is mitigated by a price point that is almost 50% higher than most other books.
  • Going with a technical publisher is better than going at it alone.  Some sites like Lulu allow you to publish your own work.  Readers usually like to stick with the big technical resource names like Manning, O'Reilly or Apress.
  • You can use NovelRank to see how your competition is doing or if there is strength in particular topics.  Using the tool, I can clearly see there is a ton of interest in iPhone development.  There are more than several books in the top 1,000 on that topic alone.
 
How are Silverlight book sales?
 
I was curious about how Silverlight book sales are doing.  This is what I saw:
  • The current best selling Silverlight book is Matthew MacDonald's Pro Silverlight 3 in C#.
  • The best selling books are targeted towards Silverlight version 3.  I think this will change when Silverlight 4 comes out in April 2010.
  • Silverlight 2 books are still selling a little.  Some books like Data-Driven Services with Silverlight 2 are still selling better because a lot of the concepts will still apply to Silverlight 3 and 4.
  • Silverlight 3 sales will continue to be strong for another several months.  The reason I say this is because of the coupling of Silverlight 4 with Visual Studio 2010.  Not all development shops are ready to move to .NET 4.0 and Visual Studio 2010.  Therefore, this will keep Silverlight 3 interest for quite some time.
  • Looking at the sales of the iPhone development books, authors for Windows Phone 7 development should make a killing in the next several months.

 

Summary

I hope you can see how an automated tool like NovelRank can help technical authors gain valuable insight into their sales, competition, make better decisions about writing a second edition, etc.  Hopefully current and future authors will find this information useful.  Lastly, use the self-service novelrank.com tool!

In a secondary point, I would like to say that this is a great example of Business Intelligence 2.0.  By using the self-service NovelRank tool, we are able to make wise decisions from real-time data.  This is a good example of a great business intelligence analytics tool that is simple and effective.

 

Posted: Apr 08 2010, 10:41 by Bart Czernicki | Comments (5) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: BI | Silverlight | Silverlight 3
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us