Notes from the PDC pre-conference session, by Jeff Prosise.
Silverlight contains an optimized subset of the full .NET Common Language Runtime (CLR). This means that if you have existing .NET libraries that only uses the subset the source code is compatible, but you cannot use the same compiled library because there are other references for Silverlight projects.
Silverlight supports Internet Explorer (5-8), Moizilla, Safari and soon also the popular Linux browsers.
Requirements to be able to develop Silverlight applications:
When compiling a Silverlight project a xap-file is crerated. The xap-file is really nothing else than a zip-file and you can tell Visual Studio to use WinZip to open the file when dubbel-clicked in Visual Studio.
Covering:
- Transformations
- Animations
- A Page-turning sample that of course uses both Transformations and Animations can be found here (check out MyComics under Recent Silverlight Projects).
- Data binding
- Styles
- Global styles is declared in App.xaml file that is created in a new Silverlight sample.
- Templates allow us to completly customize the visual representation of any control.
- Use TemplateBinding so that for example width and height still can be controlled on the individual elements.
- Use ContentPresenter in templates.
- Use Blend to do template work.
- Threading
- Full .NET support for threads, but for networking it has the same limits as the browser (two threads I think).
- Uses syncronization context in the same way as I recently bloged about.
- Networking
- Rich support; WCF proxies (BasicHttpBinding and duplex services), HttpWebRequest, WebClient, Socket support and ADO.NET data services
- Cross-domain if policy files exists on the server
- Cross-protocol (downloaded over http, but calls over https) with Silverlight policy file (see this blog by Tim Heuer)
- HttpWebRequest does not support relative URI's and only asynchronous calls
- WCF proxies only asynchronous calls
- Sockets requires policy file also for the same domain and only supports TCP over port 4502-4532 only.
- Browser integration
- Listen to events from html elements.
- Call javascript functions.
- Typed access to html elements.
- Type marshalling between .NET types and javascript types.
- File I/O
- OpenFileDialog (but not SaveFileDialog)
- Isolated Storage (Max 1Mb per domain is the default max quota. This means that all applications from the same domain share this quota, but it is possible to ask the user for more.)
Silverlight supports three markup extensions (wpf has a lot and you can do your own); Binding, TemplateBinding and StaticResource. Silverlight does not support DataSets. Worth noticing is that you could move all javascript code to compiled C# code and not using any of the visual fetures of Silverlight if you want.
Suggestions for interview questions by Jeff:
- How to pass typed .NET objects to .NET methods from javascript?
- Redmond zip-code (Answer: 98052)
- And a lot more (most fun), but unfortunately I started to write them down too late.
I wish I had some playtime, so that I could create a sample application, that preferably answered the question how easy (or hard) it would be to share a UI for both Silverlight and a full WPF version.
Useful links: SilverlightSpy, SilverlightContrib (Controls and other libraries)
Blogs: Tim Heuer's blog (must read for Silverlight developers), UX Musings (has some styles available for download)