Microsoft has just released the Silverlight 4 RC with several changes in the Silverlight runtime & in the Silverlight tools. Though there are couple of changes since Silverlight 3 & since Silverlight 4 Beta but it supports most of the Silverlight 3 applications by using Quirks mode. In some cases your earlier application will break or behave differently.
In this post I will describe you both the breaking changes in Silverlight 4 since Silverlight 3 & Silverlight 4 Beta. But before going to the discussion on the breaking changes, let me tell you what is Quirks mode. Quirks mode is a behaviour by which your previous application will work on the new runtime. Simple example is that, if you have Silverlight 3 compiled application it will try to run in Silverlight 4 (some cases it will fail) using quirks mode but if you compile the same application in Silverlight 4 it will not use the quirks mode and through errors on the changes.
What’s new in Silverlight 4:
- XAP Signing
- Custom Chrome Window
- WebCam/Mic Configuration Preview
- Text position and Selection API
- Pinned full screen mode on secondary display
- Support for Private Browsing
- RichTextBox XAML clipboard format
- Elevated apps doesn’t have Sockets Security Restrictions
- Support for querying printer page size and printable area
- XmlnsPrefix & XmlnsDefinition attributes has been added
Breaking Changes since Silverlight 3:
So, lets start with describing the breaking changes in Silverlight 4 since Silverlight 3.
- Mouse Wheel Support - Silverlight 4 controls (ListBox, TextBox, ComboBox, ScrollViewer, Calendar, DatePicker, DataGrid) now have support for Mouse Wheel.
- Shared BitmapImage Source – Now Silverlight 4 will render the images properly if more than one Image controls are sharing the same BitmapImage source.
- ImageBrush.ImageSource returns ImageSource – ImageBrush.ImageSource in Silverlight 4 now returns ImageSource instead of UriSource which could be WritableBitmap or BitmapImage.
- Keyboard Navigation in TabControl – Keyboard navigation in TabControl was a feature in Silverlight 3 having an issue with the TabItem activation. Previously pressing Up Arrow activated the next TabItem and pressing Down Arrow activated the previous TabItem. In this release they fixed it to properly activate the TabItem. In Silverlight 4 if you press Up Arrow it will activate the previous TabItem & pressing Down Arrow will activate the next TabItem.
- Automation focus in DataGridCell - DataGridCell now receives automation focus when currency changes in the DataGrid, rather than focusing on the other part of the DataGrid.
- Hit Test while Toggling Full Screen Mode – While toggling full screen mode Silverlight 4 will now rerun hit testing. This allows controls that were under the mouse before toggling to update the MoouseEnter state if necessary.
- Whitespace handling with Span tag – TextBlock and RichTextArea now accepts text content & creates implicit runs generating whitespaces between inlines separated by CRLF.
- DisplayMemberPath & ItemTemplate recreates all containers – Silverlight 4 now recreates all containers by invalidating them while there is any change in DisplayMemberPath or in ItemTemplate properties of the ItemControl.
- New XAML Parser – Silverlight 4 now includes all new XAML Parser along with the previous XAML Parser. As per the runtime version detected in the application manifest it will parse the XAML in the appropriate parser. Apart from that, it has now additional benefits like “Better XAML compatibility”, “Greater parsing correctness & consistency”, “Better feedback error mechanism”, “Performance improvement”.
- Panels Clear() method calls InvalidateMeasure – If you call the Clear() method of the Silverlight 4 panel it will now explicitly call InvalidateMeasure.
- Virtualizing Stack Panel now scrolls by 3 lines – Mouse Wheel scroll in Silverlight 4’s Virtualizing Stack Panel will scroll by three (3) lines instead of one (1) line.
Breaking Changes since Silverlight 4 Beta:
If you were exploring Silverlight 4 Beta this section will be most important for you. There are some changes in both the runtime & tool since the beta release. So before starting with that please read the same carefully.
- Removed TextSelection.CanInsert – TextSelection.CanInsert is now no longer available in Silverlight 4.
- RichTextArea changed to RichTextBox – RichTextArea now renamed to RichTextBox.
- RichTextBox.TextDecorations no longer exists – RichTextBox.TextDecoration is not available now. Instead of it you can use Inline.TextDecorations.
- Default value to RichTextBox.TextWrapping – Silverlight 4 now has a default value of RichTextBox.TextWrapping to Wrap. If you don’t want to wrap your content you have to explicitly set it to NoWrap.
- HtmlBrush renamed to WebBrowserBrush – In Silverlight 4 HtmlBrush now renamed to WebBrowserBrush.
- COM Interoperability – COM Interoperability types are now moved to System.Runtime.InteropServices instead of System.Windows.Interop namespace.
- WebCam/Output Protection Support – There has been a huge changes in the webcam/output protection support:
- CanEnableHDCP renamed to CanEnableHdcp
- CanEnableCGMSA renamed to CanEnableCgmsa
- VGA, DVI, HDMI, LVDS, SDI, UDIExternal, UDIInternal also renamed to similar naming convention
- VideoFormat.Height and VideoFormat.Width renamed to VideoFormat.PixelHeight and VideoFormat.PixelWidth respectively
- AsyncCaptureImage call now changed to CaptureImageAsync
- NotificationWindow – NotificationWindow.Visible property has been changed to NotificationWindow.Visibility