Click here to Skip to main content
15,881,281 members
Articles / Programming Languages / C#

Silverlight Dynamic Themes

Rate me:
Please Sign up or sign in to vote.
4.92/5 (11 votes)
6 Jan 2012CPOL6 min read 56.5K   5.9K   29  
This article describes how to dynamically apply themes to a Silverlight application.
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
    xmlns:my="clr-namespace:System;assembly=mscorlib" >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <FontFamily x:Key="HeaderFontFamily">Segoe UI Light, Lucida Sans Unicode, Verdana</FontFamily>
    <FontFamily x:Key="ContentFontFamily">Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>

    <!-- Font Sizes. -->
    <my:Double x:Key="DefaultFontSize">11</my:Double>
    <my:Double x:Key="InputFontSize">10</my:Double>
    <my:Double x:Key="NormalFontSize">10</my:Double>
    <my:Double x:Key="Heading1FontSize">34</my:Double>
    <my:Double x:Key="Heading2FontSize">22</my:Double>
    <my:Double x:Key="Heading3FontSize">19</my:Double>
    <my:Double x:Key="Heading4FontSize">16</my:Double>
    <my:Double x:Key="Heading5FontSize">13</my:Double>
    <my:Double x:Key="Heading6FontSize">9</my:Double>

    <my:Double x:Key="ApplicationNameFontSize">48</my:Double>
    <my:Double x:Key="HeaderFontSize">18.333</my:Double>
    <my:Double x:Key="NavigationFontSize">26</my:Double>

    <my:Double x:Key="ContentFontSize">12</my:Double>
    <my:Double x:Key="HyperlinkFontSize">12</my:Double>
    <my:Double x:Key="LabelFontSize">10</my:Double>
    <my:Double x:Key="ControlTitleFontSize">13</my:Double>
    <my:Double x:Key="ControlTitleBigFontSize">13</my:Double>
    <my:Double x:Key="ControlContentFontSize">9</my:Double>


</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Romania Romania
I have been a software developer for a while and still find this an interesting job.

Comments and Discussions