I saw the light Issues of Silverlight style system - Alexey Zakharov's Blog

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.

Published Wednesday, October 14, 2009 9:15 AM by brainbox
Filed under:

Comments

# re: Issues of Silverlight style system

Friday, October 16, 2009 5:15 AM by Rishi

I know this is a big problem, something I'm also trying to get around. Now, I've not gone into it technically yet, but a possible solution could be to declare a static relay and then at runtime provide an implementation. Another solution is detailed in this post, which I like but I've not tested it yet. Have a look www.markusegger.com/.../Development.aspx

Cheers

# re: Issues of Silverlight style system

Saturday, October 17, 2009 3:16 PM by brainbox

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 =)

# re: Issues of Silverlight style system

Sunday, October 18, 2009 12:43 PM by Rishi

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?

# re: Issues of Silverlight style system

Sunday, October 18, 2009 1:05 PM by brainbox

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.

# re: Issues of Silverlight style system

Monday, October 19, 2009 2:32 AM by Rishi

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.

# re: Issues of Silverlight style system

Monday, October 19, 2009 5:42 AM by Alexey

Heh.. Silverlight is A BIG HACK =)

# Silverlight Cream for October 19, 2009 -- #711

Tuesday, October 20, 2009 12:40 AM by Community Blogs

In this Issue: Davide Zordan , SmartyP , Corey Schuman , Gavin Wignall ( 2 ), Jeff Paries , Vikram Pendse

# re: Issues of Silverlight style system

Tuesday, October 20, 2009 5:26 AM by Pete the Geek

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.

Leave a Comment

(required) 
(required) 
(optional)
(required)