Silverlight Straight Talk: The Awesomeness, Disadvantages, and Difficulties in Silverlight

Building Silverlight application takes time, effort, patients, and tools (yes, you have to have some tools). In this post we will cover: where to get the necessities and some useful additional tools, as well as straight talk about the awesomeness, disadvantages, and difficulties of building Silverlight applications.  We will also cover the basics of XAML, referencing and using related assemblies, and the how Expression Blend and Visual Studio make it all happen.



Where to Get the Necessities

Must Have tools

  • Visual Studio.NET 2008 or 2010 (available from the link above)
  • Expression Blend 3 (available from the link above)
  • Silverlight Spy
  • Fiddler Debugging Tool
  • FireFox with FireBug(Tools àAdd-ons àGet Add-ons)

Useful Additions

Straight Talk: the Awesomeness, Disadvantages, and Difficulties in Silverlight

  1. You, as a developer, now can and should learn how to developer professional grade User Interfaces that offer end users an engaging and user friendly experience. You will take on both the role of Designer and Developer.
  2. The things that you wished you could do in C# instead of JavaScript can now be done, this frees you from the limitations of the typical web application.
  3. The learning curve: its steep (but not mount Everest)
  4. XAML, it’s a whole new world.
    • Its an unfamiliar landscape that takes time getting used to (remember the first time you ever worked with HTML and CSS, its just like that)
    • Its very picky and unforgiving, one wrong move and you get an very unhelpful BAD PARSER error forcing you to literally dig through all of your code to try and figure out what the problem it.
    • Blend, it’s a whole new tool (even if you already know Adobe Photoshop)
    • You have to find your way around the tool, its not obvious how to do a lot of things , expect to spend lots of time and energy getting used to it
  5. Visual Studio and Blend: it takes two to tango
    • You really must have Blend in order to develop complex (or even average) Silverlight applications
    • Animation and themes are pretty much done exclusively in Blend.
    • All your C# coding is done in Visual Studio
    • Reliable Error message don’t exist, this increases the time and difficulty in tracking down issues.
  6. Gotcha’s that will drive you nuts
    • If you don’t explicitly set the Forecolor (a.k.a the font color) on your TextBlock then your text wont show up (even though it looks fine in Blend)
    • Your project can get out of synch when working in both Blend and Visual Studio, if your not careful you can end up undoing a lot of your code
    • The Design View in Blend can screw you! Don’t rely on it exclusively, instead always be looking at the Code Window (Split View) when working with the designer
    • No Project Refresh in Blend: After adding items to your project through visual studio you have to trick Blend into reloading the project in order to work with the additions.
    • Bland fails to apply namespace properly when using it to add new User Controls
    • Selecting an Image source through the designer copies the image to the Silverlight Application Root
    • Blend doesn’t recognize Web Service References and will indicate that you have errors when you really don’t
    • Error Message are worthless.

Understanding the basics

  1. UI layout
    • Grids: they are very much like HTML Tables
    • Stack panels: this is like an HTML Div where you set the “orientation” of its contents to one of two setting, either Horizontal (default) or Vertical
    • Canvases: just like it sounds, it’s basically a container where you position its content using Canvas.Top=“x” and Canvas.Left=“x”. Very similar to using a Top and Left in HTML/CSS
    • Margins: allow you to add spacing between items (left, top, right, bottom) in order to control its position relative to other objects. Just like Margin/Padding in HTML/CSS
  2. Animations
    • Visual State Manager: this is the build in “animation” that is applied to object. Is usually developed using Blend because it can be a nasty little bugger to work with by hand.
    • Animation using Blend: similar to how you animate object in Flash (“Tween” like features as well as Easing)
    • Behaviors: these are “In-Code” animations (basically taking an animation that Blend creates and writing it in C#). Can be reused through your project as well as other projects (by adding references to the DLL its contained within). Not easy to create because currently there isn’t any automation tools to write the C# code (you will be doing by hand, not fun).
  3. Events and Data-Binding
    • Getting a grip on Asynchronous Data Exchange: timing is everything, your data may take a long time to return (if it returns at all) and you need to let people know what’s happening during this time. Data returned is not guaranteed to be returned on the User Interface Thread, meaning it may be there but not show up in the UI
    • Data-Binding and why it’s so awesome in Silverlight: Binding objects to data is INSANELY easy. Objects look for data that it should bind to first in its own DataContext, then its Parent, then its parents parent, etc… until it finds (or doesn’t) what its looking for. Handles “not found” very graciously.
    • Accessing your web services: set-up to easily handle moving from Dev to Test and then into the Production Environment
    • Wiring events to User Controls: very similar to how you define it in ASP.NET web applications.

References assemblies & debugging your project

  1. Accessing and Using Shared Components
    • Using Blend’s Control Library to access items in referenced libraries. In Blend you can access controls that exist in references library (DLL’s).
    • Extending existing controls in order to customize them: accomplished in the same way as ASP.NET, simply create a Class file that inherits from the base control (i.e. the Textbox control) and add custom properties and methods to it. Then use these in your project in order to take advantage of the added functionality.
    • DLL’s as well as “Behavior” classes (just C# class files), many available for Free on the Web (visit  )
  2. Testing and Debugging your application
    • Using Fiddler to intercept web service requests (very useful to debug web-service requests and responses)
    • Using Silverlight Spy to identify User Interface elements (a must-have tool to drill down on the Silverlight objects displayed on the screen)
    • Unit Testing your Web Services and Business Logic