I’ve been working in Silverlight recently and I’ve slowly been discovering that as simple as it can be to develop, there are one or two annoying gotchas that lurk in the shadows.
Considering how difficult some of these have been to track down for me, I thought it might be useful to list them here on SO for others to benefit from. I’m sure the ones I have encountered are nothing compared to the experience of others and I’d like to try and avoid any other nasty or time consuming surprises.
So, what have you got?
Update
I’ve updated this to cover Silverlight in general. Therefore, please provide a version or list versions to which the gotcha relates when responding. For all those without a version, please assume Silverlight 2.0 as this was the case in the original question.
The two that I’ve experienced are:
Cross Domain Policy Files
For Silverlight to work with Web Services that are hosted on a different domain, the server needs a cross domain policy file. This can take two formats:
I couldn’t get the former to work properly but the latter worked (Flash uses the second one whereas I believe the first is specific to ASP though I couldn’t get it working under an ASP.NET 2.0 server, so it may be 3.5-specific).
ComboBox dropdown resizing
The Silverlight 2.0 combobox control only sizes its dropdown area once, when it is first shown. It therefore bases it’s size on the initial items in its list. That means 2 items will give you a 2 item high dropdown, even when the list increases to 200. The only way around this appears to be to replace the combo with a whole new control each time the items change.
Note that setting the Height property or the MaxHeight property to a value that leads to items appearing off the list in the initial display of the dropdown will lead to an absence of a vertical scrollbar and therefore, an absence of access to items in your list. The only solution I found to that was to use the MinHeight property to at least have a decent height for all uses and just let it be bigger if the items exceed that minimum height.
Also, when you resize the browser window, regardless of whether you use MinHeight or not, and then either dropdown the combo list or you resize while it is visible, this can irreversably decrease the size of the dropdown.
Update
Here is a really nice solution to the combo problem, thanks to markti.