Silverlight Limitations

August 21, 2008 01:59 by wjchristenson2

Over the past couple of weeks, I've been working daily with Silverlight 2.0 b2.  I've attempted to do certain things in XAML and in my code that simply were not supported.  I know these features were available to me when I did some WPF development awhile ago and I know that some of the .NET objects I wanted to use programmatically are available in the .NET framework, however they are not available in Silverlight. 

What I found first, was a limitation of triggers.  I went to create a simple style change when the user hovered over a button (a style trigger).  I quickly found out that style triggers are not supported.  Digging a little deeper, I found out that Silverlight 2 b2 only supports the EventTrigger.

I then went to use an ArrayList and it was not supported.  I found a nice article written by Inbar Gazit of the Microsoft's Base Class Library team.  A few non-generic collections of the .NET framework are not supported in Silverlight.

Collections Not Supported by Silverlight:

  • ArrayList
  • BitArray
  • CaseInsensitiveComparer
  • CaseInsensitiveHashCodeProvider
  • CollectionBase
  • Comparer
  • CompatibleComparer
  • DictionaryBase
  • EmptyReadOnlyDictionaryInternal
  • Hashtable
  • IHashCodeProvider
  • KeyValuePairs
  • ListDictionaryInternal
  • Queue
  • ReadOnlyCollectionBase
  • SortedList
  • Stack
  • Inbar explains, "Three other generic types were also removed. Queue, Stack and LinkedList were removed from Silverlight. In this case it wasn't because they were non-generic but because they are not considered to be part of the core set of types that we deemed essential to be provided with Silverlight. Remember that Silverlight is a very small download and should only include the smallest set of APIs that will allow for useful development. It's very simple to implement Queue and Stack using List and LinkedList is just a different implementation of List with different performance characteristics and so it's not an essential part of our core collections group."

    ** Edit 9/30/2008 **
    I've found a few more limitations as I've been developing in SL2B2.  First, you can only use the Grid, Canvas, and StackPanel to organize the layout of our SL2B2 application.  Layout mechanisms you may have used in WPF (WrapPanel, DockPanel, etc), are not supported.

    You cannot set default values for dependency properties via the dependency property's metadata.  If you wish to set its default value, check this post out.

    You cannot set dependency properties that are of the Nullable(Of T) generic structure type via XAML.  You will get XAML parser exceptions.

    Bookmark and Share