dex3703
dex3703

Reputation: 2107

Silverlight 4: change themes/styles for whole app without using Toolkit

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:

Thanks.

Upvotes: 0

Views: 2242

Answers (2)

vortexwolf
vortexwolf

Reputation: 14037

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

Upvotes: 1

Ken Smith
Ken Smith

Reputation: 20445

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.

Upvotes: 0

Related Questions