Silverlight 2 Knowledge Base

Edit

Style

Siverlight style bears a resemblance to HTML CSS style. It allows us to define a group of properties as a style as later apply the style to one or more controls.

The styles are defined as resource at the application level (app.xaml) or a page level (e.g., mypage.xaml). For example:

    <Application.Resources>
         <Style x:Key="TBoxNormal" TargetType="TextBox">
             <Setter Property="FontFamily" Value="Arial"/>
             <Setter Property="Margin" Value="5,5,5,5"/>
             <Setter Property="FontSize" Value="10"/>
         </Style>
    </Application.Resources>

Later, you might set the style to the Style property of the control as:

<TextBox x:Name="txtName" Style="{StaticResource TBoxNormal}" />

See the following examples for example for Style:

Style and Templates Silverlight Tutorial Part 4 - Using Style Elements to Better Encapsulate Look-And-Feel

Edit

Control Template

Some Silverlight controls allows us to customize the appearance of a control by specifying the visual structure and visual behavior of a control.

See the following tutorial for information:

Customizing the Appearance of a Control with a Control Template Customizing the Appearance of an Existing Control by Creating a ControlTemplate

Edit

Skin

Skin is not an official Silverlight term. However, it has often been used to refer to placing control templates in application or page resources so that the templates can be applied to multiple controls. That is, in effect, like "skinning" a control. For example, see How to: Share Content Among Controls.

Edit

Theme

Silverlight Theme is part of Silverlight Toolkit. The term was originally used by Nikhil Kothari to refer to an mechanism that he created to extracted control templates from static resources so that different set of templates can be applied at runtime.

As of 10/28/2008, Microsoft has released 6 themes in Silverlight Toolkit:

  • Expression Dark
  • Expression Light
  • Rainier Purple
  • Rainier Orange
  • Shiny Blue
  • Shiny Red

Edit

Applying Themes

There are two way to apply theme Edit

Customizing Themes


Edit

Effect

(c) Li Chen 2008. ScrewTurn Wiki version 2.0.37. Some of the icons created by FamFamFam.