Issues of Silverlight style system

 Perhaps the second annoying problem after incomplete binding support is poor style system of Silverlight.

Here is the main two issues.

1. Styles are not compatible with on demand application loading. Imagine you want to share style dictionary among a set of application modules (something like PRISM module). The source of problem is xaml reader, which parse resource dictionary with shared style. To successfully parse dictionary it requires all controls dll to be loaded. But these controls dll are loaded on demand if module needs them.That is why if you for example load module A which doesn't requires any control libraries, but uses shared style dictionary u will get XamlParseException. We are currently hacking this issue by manual resource dictionary parsing. But it is just another dirty HACK!

2. Silverlight doesn't support dynamic resource so it is not impossible to create application themes (What you see in toolkit is just a Hack that is not support changing of theme and works rather slowly). You simply cannot change style of element if it was set once.

 If you have and ideas how to solve it or you are Microsoft guy ;-) which can fix it please email me or leave a comment.

7 Comments

  • We have very dirty solution that works... We try load all styles one by one. If XamlLoader throws exception we skip them. Once new module are loaded we recheck styles that are still don't loaded.

    I haven't noticed any performance issues. But u know.. It looks like total rubbish =)

  • Sorry, you load the styles one-by-one into what/where? Is it the main resource dictionary or the root visual's resources collection? And I suppose in this case the order of loading would also matter, right?

  • We have our modular framework similar to prism. At first when we are loading shell we are trying to load all styles from resource dictionary which hold shared styles.

    We parse it with Linq to XML and try load every styles separately with xaml loader (try { xamlLoader.Load.... } catch { try this style later.. }

    When new module are loaded we try load the rest of styles again.

    Currently we loading them into dynamically created empty merged resource dictionary.

    The loading order matters. But we cant break it with such lazy loading manner.

  • Understood, thanks. I'll try this and a relaying approach, though all this will remain hack'ish till it is rightfully addressed at the framework level. Hopefully, in SL4.

  • Heh.. Silverlight is A BIG HACK =)

  • The best way of loading themes involves dynamic loading of styles from the server and parsing them into the App Resources. You are correct in that the order of loading must reflect the dependancies of one style on another and must occur before you load the root element of your application.

  • So-so. Something was not impressed.

Comments have been disabled for this content.