With Silverlight 4.0 there are some changes done in
XAML parser. In this article I am going to cover some of the main changes done
in XAML parser.
In Silverlight 3.0 we had to use attribute syntax for caption
This was the one of the inconsistency present with WPF.
Now the Silverlight control has better
In previous version of Silverlight, the XAML parser was
showing whitespaces, it didn't remove whitespaces available in text.
When you run the application you will get this output.
The Silverlight 4.0 XAML parser has handled whitespace
behavior. Also it provides support for older version (when you are migrating
from older version of Silverlight to Silverlight 4.0, this may be useful).
If you run the same above code you will get this output.
To go back to previous version behavior you can use xml:space="Preserve"
Now in XAML you can add items to dictionary just like
we do in Resource Dictionary using "x:Key"
In Silverlight 4.0, any type or property implements
IDictionary can be used in XAML. This is useful in complex XAML scenario when
you want to declare dictionary rather than a list.
Note that, the above is for non-generic IDictionary
Many bugs around error handling are fixed. In older
version of Silverlight the biggest complain about XAML was poor error handling.
Now errors are more descriptive like in WPF.
When using different library or Silverlight toolkit you
have to specifically define xmlns in every pages, for every assembly you want
Now with XmlnsDefinitionAttribute you can do this with
less code, all the assembly in the product can share same namespace which can
then be defined only once.