My Photo
Blog powered by TypePad
Member since 11/2005

July 2008

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Sense

  • Google

« The RIA pattern | Main | WebManiacs 2008 - Early Bird Ending Soon »

10 March 2008

Silverlight 2 Beta

I wanted to get my hands on Silverlight 2 beta, writing a sample app to understand the experience. I half expected Silverlight to be an enormous, complex, sophisticated platform rivaling WPF - after all, it was initially named WPF/E. On the contrary, I was surprised to see the number of simplifications to the framework. Here is a brief list of WPF features that are not available in SL 2.0:

  • Standard controls; like Button, TextBox, ListBox, CheckBox, etc.
  • Layout panels
  • Data binding
  • Templates
  • Styles
  • Commands
  • Routed events
  • A majority of events on elements (available in WPF)
  • A resource system based on merged resource dictionaries
  • Visual and logical trees (no programmatic construct represents them, at least)

Once I got past all those missing bits I found that what does currently exist is actually quite cool and useful.  The set of controls that are supplied look great and in the demo app they seem to work quite well.

I must admit, though, I really miss routed events.  With events such as tunneling and bubbling, working with normal CLR events is really limiting.  However, if I am correct, Microsoft intends on adding routed events into Silverlight 2.  The EventTrigger class exposes a RoutedEvent property as in WPF - it is possible that they named Siverlight’s EventTrigger’s property “RoutedEvent” to ensure that the Silverlight XAML compiles in WPF, but perhaps they actually intend on implementing routed events in the future.  Think about it, what sense would it make to have a property called RoutedEvent if routed events do not exist in Siverlight?

Another thing is that it is difficult, if not possible to use inheritance in a UserControl. According to the Silverlight.net forum, this is a "limitation". Even if the Base class inherits the UserControl class, you will see this error:

"Partial declarations of 'CLASSNAME' must not specify different base classes" in the file CLASSNAME.g.cs (g = generated). 

When you open the .g.cs file and remove the base class from it, the project compiles fine and also seems to work fine.

To address this issue, see this thread: http://silverlight.net/forums/p/10970/34988.aspx. As such, while it is possible, it has some peculiarities. For instance, when opening a file in Blend, it throws an error. When you have no need for that, it's no problem, but IMHO designers should still have the ability to change things in the design after I used inheritance on the control.

Additionally, when having multiple Silverlight pages (or applications as they are called now) in a single Silverlight Project it seems impossible to load any other than the default Page.xaml:   

- When using the "html" <object> method: it expects a parameter with a xap file, xaml files are not allowed
- asp:Silverlight control also needs a xap file. asp:xaml doesn't work
   
This could be my lack of experience in Silverlight 2, but again, it's my first impression. If I find a way this does work, I'll add it as a comment to this post. There is an option by setting an initParam with the name of the startup control you want to use. I'm not sure if I like this option, but it's a workaround.

I am also uncertain as to whether the Webclient is an improvement over the Downloader. For a simple thing as loading an image from a zip file: 

1.1 alpha code:

codesnippet1

2 beta code: 

codesnippet2

More lines of code, which doesn't necessarily mean that it's a worse solution than the SL1.1 one, but it definitely makes it more error prone. 

I think that MSFT wants to support bitmap effects such as those provided by Flash (blurring, etc). Maybe that's the reason they chose for the addition of a bitmap object. Time will tell.

Silverlight 2 beta is also inconsistent when it comes to relative URI.    The relative path should be the path from the root of the website, as it is in Silverlight 1.0 and 1.1.

In Silverlight 2 beta , the path in design is relative to the root of the site, but when running the app, it is relative to the location of the XAP file. So when downloading "thumbnails.zip" using the WebClient it looks for thumbnails.zip in the ClientBin folder instead of in the root of your website. 

Setting the WebClient.BaseAddress to the root of the site doesn't seem to work either.

   

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/597508/27417472

Listed below are links to weblogs that reference Silverlight 2 Beta:

Comments

Post a comment

Comments are moderated, and will not appear on this weblog until the author has approved them.

If you have a TypeKey or TypePad account, please Sign In