Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #91 – How to Apply Themes from the Silverlight Toolkit

In addition to controls, the Silverlight Toolkit comes with a great set of themes that can easily be applied to your controls. These themes currently include:

  • Bureau Black
  • Bureau Blue
  • Expression Dark
  • Expression Light
  • Rainier Purple
  • Rainier Orange
  • Shiny Blue
  • Shiny Red
  • Whistler Blue

You can see a sample preview of each of these themes by visiting this link.

In this Tip I will be showing you the necessary steps to get a theme applied to your Silverlight controls.

Step 1. Add a Reference to the Theme Components.

  1. In your Solution explorer right click on “References” and choose “Add Reference”.
  2. Browse to the location where you installed the Silverlight Toolkit binaries (i.e. c:\SilverlightToolkit\Binaries).
  3. Add Microsoft.Windows.Controls.Theming.
  4. In my demo I will be using the Shiny Red theme so also include a reference to Microsoft.Windows.Controls.Theming.ShinyRed.dll which is located in the Binaries\Themes folder.

Step 2. Add Namespace Declaration

  1. Open Page.xaml and add the following statement to your UserControl to reference the ShinyRed component.

<UserControl x:Class="MapEditor.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns:shinyRed="clr-namespace:Microsoft.Windows.Controls.Theming;
assembly=Microsoft.Windows.Controls.Theming.ShinyRed"
Width="800" Height="600">

Step 3. Apply the Theme to a Control

Declare the ShinyRed theme around any control you want to apply the them to like this:

<Canvas>
    <shinyRed:ShinyRedTheme>
        <Button Content="Save Map" Click="Button_Click_Save_Map" Width="80"></Button>
    </shinyRed:ShinyRedTheme>
</Canvas>

Result:

As you can see in the image below, the theme is directly applied to the button.

image

Thank you,
--Mike Snow

 Subscribe in a reader

Comments

Microsoft Weblogs said:

In addition to controls, the Silverlight Toolkit comes with a great set of themes that can easily be

# February 9, 2009 2:22 PM

Community Blogs said:

In this issue: Martin Mihaylov, Radenko Zec, Terence Tsang, Mike Snow, and Shawn Wildermuth. Shoutout

# February 9, 2009 6:59 PM

Dew Drop - February 10, 2009 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - February 10, 2009 | Alvin Ashcraft's Morning Dew

# February 10, 2009 10:17 AM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight Tips of the

# February 10, 2009 6:22 PM

Visual Web Developer Team Blog said:

Most Recent Posts: Tip #93 - Reading XML with Silverlight Tip #92 - How to Load Images from a Stream

# February 10, 2009 6:25 PM

zaakiy said:

Help! - I cannot find Microsoft.Windows.Controls.Theming in the March Toolkit!

# April 21, 2009 9:12 AM

NewsPeeps said:

Thank you for submitting this cool story - Trackback from NewsPeeps

# August 8, 2009 6:35 PM

tjc59 said:

Does anyone know why the theme doesn't apply to a datagrid? My column headers show up, but my items are blank.

# August 13, 2009 4:09 PM

furrybaer said:

Does it have to be wrapped around the control?  Can I set a property IN the control?

thanks

# September 15, 2009 2:41 PM