This article is based on Silverlight 5 in Action , published on June 2011. It is being reproduced here by permission from Manning Publications. Manning publishes MEAP (Manning Early Access Program,) eBooks and pBooks. MEAPs are sold exclusively through Manning.com. All pBook purchases include free PDF, mobi and epub. When mobile formats become available all customers will be contacted and upgraded. Visit Manning.com for more information. [ Use promotional code ‘java40beat’ and get 40% discount on eBooks and pBooks ]
Silverlight 3, 4, and 5 have added an amazing number of new capabilities to the platform in all areas, from core capabilities, to device access, to the introduction of both trusted and sandboxed in and out-of-browser client applications. While Silverlight is still a relatively young technology, it has had 5 major releases in the past four years, as described in table 1.
Table 1 shows just a few of the major enhancements delivered in each version of Silverlight over the last four years. In the remainder of this article, we’ll look at the features, especially those new to Silverlight 4 and 5, in more detail. The advancements in Silverlight can be loosely grouped into four main areas: business and client applications, media and graphics, user interaction, and text.
Features for business and client applications
Though Silverlight 2 could have been used to build rich business applications, it didn’t have the chops to be a strong contender in that space yet. Three versions later, that story has certainly changed. Many of the features in this article are useful in applications of all sorts; I hate to classify them under the heading of “business,” but that’s the largest consumer of these features.
Validation was one of the biggest new features for business applications. Silverlight didn’t add just validation but included support for validation through attributes, validation through exceptions, and even asynchronous validation, all of which work with the Silverlight controls. Silverlight even made it possible to completely customize the style of the validation information provided to the end-user.
One technology that builds heavily on the validation stack is WCF RIA Services. A good bit of the validation functionality rolled into the Silverlight runtime actually came from that project. WCF RIA Services provides a way to share validation and logic between the client and the server as well as a framework for validation, data access, and security, shareable between Silverlight and other clients.
WCF RIA Services builds upon the WCF stack, but it’s not the only enhancement there. The Silverlight networking stack was greatly enhanced to support in-browser and out-of-browser operation, as well as SOAP 1.2 and a number of new protocol enhancements, including WS-Trust. We’ve also done a lot to optimize networking performance and reduce latency in Silverlight 5. These changes make it easier to use Silverlight behind a firewall where the services often have different requirements than those on the Internet.
Despite the promises of a paperless office, printing is still a staple of business applications everywhere. Printing in Silverlight 4 was optimized for relatively short reports or documents, as well as for the equivalent of print-screen operations. Silverlight 5 adds a new Postscript or true vector printing mode to the existing bitmap approach, making serious printing and print-preview now possible.
Finally, we come to a biggie: out-of-browser sandboxed and trusted applications. Out-of-browser mode was one of the most significant enhancements made to how Silverlight operates. Silverlight 3 introduced the basic out-of-browser mode with a sandbox roughly equivalent to the one in browser. Silverlight 4 opened up whole new classes of applications by adding the trusted application mode with its reduction in prompts, increased file access, and (on Windows) access to IDispatch COM Automation servers. All of these features add up to a platform that’s more than capable of being the client for our complex business applications.
One of the next major areas of enhancement for Silverlight is media.
Media and graphics enhancements
Silverlight was first and best known for its media capabilities. The Silverlight media team didn’t rest on that, instead pumping out enormous advances in media in each update to Silverlight.
Silverlight 2 included a Media Stream Source API for pushing media through the pipeline. But that API required that the bits be preencoded into one of the formats natively understood at the time. Though useful, this could lead to double-encoding and made transcoding even more difficult.
Silverlight 3 added support for pushing raw video and audio out of custom Media Stream Source implementations. As a result, you can write a managed codec for any type of media or even do something crazy like I did and use it to generate audio and video in real time for an emulator.
Speaking of codecs, one of the new codecs added was H.264 for video. H.264 has emerged as one of the most popular codecs for TV and video for devices. It was a logical choice for an additional native Silverlight format because now content producers can use even more of their content without reencoding. Silverlight 5 expanded on the H.264 support by adding hardware decoding to improve performance, especially on lower-power devices. To appeal to the same audience, Silverlight also continued to improve DRM capabilities, including the addition of offline DRM and seamless switching between DRM media sources.
One common request in the media space was for the ability to play video at double speed. Commonly called Trick Play, this has been added to Silverlight 5. Now you can watch my tutorial videos in 15 minutes instead of half an hour, with automatic pitch correction so I don’t sound like a chipmunk.
An exciting feature introduced in Silverlight 4 was built-in support for video and audio capture devices or, specifically, webcams and microphones. Though not yet quite at the level that would allow you to create a real-time video chat application, the support does open up a number of new possibilities for application development. Under the covers, Silverlight now has support for all formats of portable network graphics (PNG), something that was only partially supported in previous versions. Silverlight 4 also introduced support for pixel shaders and a set of built-in performance-tuned effects such as drop-shadow and blur.
Easily the most anticipated feature in Silverlight 5, the GPU-accelerated 3D programming interface will enable all sorts of scenarios, from games to data visualization to custom third-party 3D rendering and scene management systems. This system also provides us with the ability to have immediate-mode 2D graphics—another frequent request.
With all of these advancements plus a number of performance optimizations and even additions such as the Silverlight Media Framework, Silverlight continues its leadership in the media space, offering everything you need to build rich media-centric applications.
Sometimes what you want is more than just a media experience; you want an application that can be truly interactive. Silverlight has your back there, too.
Since Silverlight 2, user interaction has received a number of important enhancements. Two of the most requested features, mouse scroll wheel and right-click mouse support, are now baked into the Silverlight core runtime.
One of the newer and hotter user interaction mechanisms is multitouch. The ability to support multipoint interaction with the user interface, especially in kiosk and handheld/tablet scenarios, is quickly becoming a requirement for many applications. Silverlight now includes core runtime support for multipoint-touch interaction with Silverlight application.
Another user interaction piece missing from Silverlight 2 was the easy ability to show dialogs and pop-up windows (simulated) within your applications. Silverlight now not only has those but also notification toast.
Finally, all the interaction in the world has no value if your user can’t read the text on the screen. Happily, Silverlight includes plenty of improvements in text as well.
By far, the biggest improvement to text since Silverlight 2 is proper ClearType font rendering. Silverlight 2 performed only grayscale rendering, giving text a fuzzy appearance, unless you carefully picked your color schemes. Silverlight 5 has expanded on this to provide even better and faster text rendering, much like we did with WPF 4.
While ClearType may be important for font rendering in general, right-to-left or bidirectional (BiDi) text is something that’s absolutely essential for the correct rendering of many non-European languages. Silverlight supports not only BiDi text but also input method editors (IMEs) for complex composite characters for many languages, especially Asian and Middle Eastern languages.
Silverlight 5 added enhancements to better improve layout and typography. For example, multicolumn and linked text now enables magazine-like layouts with fluid text flow around other elements. Tracking and leading, always important to the typography-aware (you know, the people who go around wearing shirts that say “Helvetica”), was also added.
Finally, one great improvement to text rendering and entry is the inclusion of the rich text box control. This control allows you to display or edit text that includes multiple fonts and styles. The control can even embed other elements that can be interactive when the control is in read-only mode.
Between Silverlight 4 and Silverlight 5, we’ve seen a huge number of great features and improvements added. Before I joined Microsoft, I heard rumors about people with sleeping bags in their offices and coffee delivered by the gallon. I suspect I now know which team they work for, and I have to say that I’m “super” impressed with the results.