Question

We are embarking on our first Silverlight project, coming from WPF. It's a relatively simple web portal and we would like to avoid references to the Silverlight Toolkit, given our experience with the WPF toolkit.

I'm not much of a coder and have a couple questions related to themes:

  • Implicit styles make this easier. It seems clear you could just switch out resource dictionaries to change your theme. How do I do this without relying on the Toolkit?

  • How do I apply the styles to the entire application, like in WPF, instead of wrapping things in the theme containers? I see there is an ApplicationThemeURI you can use, but that requires the toolkit.

Thanks.

Was it helpful?

Solution

Just a note on the Siverlight Toolkit. The last time I used the WPF Toolkit (which was a while ago), I got the impression that it was more-or-less optional. I wouldn't say that the same is true of the Silverlight Toolkit. It adds a great deal of important functionality that would be difficult to implement on your own, and while it's not bug-free, it's pretty reliable. I can't vouch for every aspect of it, but we're using it extensively in a large Silverlight project (~30K lines of code), and we find it indispensable. Unless you're aware of specific issues that your project would encounter, I would recommend that you rethink your decision not to use it.

OTHER TIPS

Applying style to whole app is a simple task in silverlight 4. Put this code in App.xaml or themes/generic.xaml:

<!-- Sample style for each button in the application -->
<Style TargetType="Button">
</Style>

This article could help you: http://www.silverlightshow.net/items/Implicit-Styles-in-Silverlight-4.aspx  

You can change resource dictionary by this way:

var dict = Application.Current.Resources.MergedDictionaries.FirstOrDefault(rd => rd.Source == new Uri("Dictionary1.xaml", UriKind.Relative));
if (dict != null)
     dict.Source = new Uri("Dictionary2.xaml", UriKind.Relative);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top