Silverlight development tips (part 1)

As you guys probably know, we (Gizmox) are working on an alternative UI layer for Visual WebGui, that will be based entirely on Silverlight and as the chief architect (and CTO) at Gizmox the hard core work was on my shoulders. When at first I look at Silverlight, I admit that I did not get what the fuss is all about, but just to make things right, I now get it.

I had developed in Flash at some point of my professional life, I have even thought (long before Visual WebGui was conceived) to write a UI framework using Flash. So given my Flash experience I can now say that Silverlight is a completely different technology. In my view, Flash was born from the designer perspective and as it grow more and more popular it was enhanced to have more powerful developer tools, Silverlight on the other hand was born from the developer prospective and as such is a super powerful tool for developers. Currently, as I see it, it has some more growing up to do, but it starts from a better point than flash.

When I stated working with Silverlight, I felt like it lacks too much and that using it, as an alternative UI layer to Visual WebGui will be hard or impossible, but after I started working with it I found how much using the .NET framework in the client could be productive. We are currently preparing to release our first CTP of the Visual WebGui presentation layer, and we got to some pretty amazing results in a rather short time. That said, building a alternative Visual WebGui UI layer is easier than creating a standalone UI framework over Silverlight. This is a huge advantage for us, as we have less to work on, than other Silverlight UI frameworks (not that there are too many).

The general idea of the Visual WebGui Silverlight UI layer is that you will use Visual WebGui on the server and the Silverlight layer will reflect the changes on the server. This gives us for example data binding capabilities without actually working on this feature, as you do your work on the server side, data binding and all, and the Silverlight layer, simply reflects the changes so it does not matter if you programmatic changed the value of a TextBox or you changed a ComboBox which is binded to the same binding context. This also applies to filling up lists as the server does the data binding work and the client simply reflects the change that was made to a given ListView and so on.

There were times when I felt that I am working with a less than half baked technology, but the potential is there. As I said before Silverlight has some growing up to-do, but as I guess most of you cannot wait to put your hands on some Silverlight code. I would like to share with you my tips regarding Silverlight programming which I hope will help you guys in your developments.

Silverlight 1.1/2.0 is in alpha, so from time to time you will get a very strange error like "Catastrophic failure" or Silverlight will decide that the browser needs to rest and will save you the time on clicking on the close button. In time we have developed certain strategies and gathered some Do's and dont's which helped us work around these issues.

Here are some of them:

  • I guess it is the case with working with any alpha framework, but it is crucial to do a general testing every now and then so you can isolate the reason why Silverlight is giving you the "Catastrophic failure" or as I said before, close the browser for you (crash).
  • If you have a "Catastrophic failure" it is in most cases related to [Storyboard].Begin() of [Canvas].Children.Add([child]). Silverlight is very sensitive regarding its storyboards and if they contain minor glitches such as you are trying to animate the opacity but the target element does not have an opacity attribute, you get an "Catastrophic failure" exception. Regarding Children collection, it does not like it if you are trying to connect a child which is already connected, so you will get the "Catastrophic failure" exception here as well.
  • Working with the XmlReader on firefox has some issues which one of them can be found here with a workaround included.

Thats all for now... I guess I am missing lots of tips, but I will write them down from now on constantly.

 

No Comments