ComponentOne Scheduler for WPF and Silverlight
Scheduler Components and Controls / Scheduler for Silverlight Appearance / C1Scheduler WPF Themes / Setting the C1Scheduler Theme
In This Topic
    Setting the C1Scheduler Theme
    In This Topic

    When C1Scheduler is first added to your project, it is formatted with the Office 2007 Default theme. If you want to use a different theme, there are several ways to select a new one.

    To set the theme at design time in Visual Studio:

    1. Right-click the C1Scheduler control.
    2. Select Theme and choose one of the seven predefined themes.
    Note: You can also change the theme through the Properties window by selecting the option from the drop-down list next to the C1Scheduler.Theme property.

    To set the theme in Microsoft Blend, change the C1Scheduler.Theme property at design time:

    1. Select the C1Scheduler control in your XAML window or page.
    2. In the Properties panel, under View, click the drop-down arrow next to the C1Scheduler.Theme property and select Reset.
    3. Click the C1Scheduler.Theme drop-down arrow again and choose one of the predefined themes.

    To set the theme using the ResourceID, use the following XAML:

    XAML
    Copy Code
    <c1:C1Scheduler x:Name="scheduler1" Theme="{DynamicResource
    {ComponentResourceKey ResourceId=Office2007.Silver,
    TypeInTargetAssembly={x:Type c1sched:C1Scheduler}}}"/>
    

     

    To set the theme using C1SchedulerResources static fields, add the following code to your project:

    Visual Basic
    Copy Code
    Scheduler1.Theme = C1SchedulerResources.Office2007Silver
    

     

    C#
    Copy Code
    Scheduler1.Theme = C1SchedulerResources.Office2007Silver;
    

    To set the theme by defining a ResourceDictionary and DefaultThemeKey in your Page, Window, or Application resources, use the following XAML:

    XAML
    Copy Code
    <Page.Resources>
                <ResourceDictionary>
    <ResourceDictionary x:Key="{x:Static my:C1Scheduler.DefaultThemeKey}"
    Source="/C1.WPF.Schedule;component/themes/SchedulerThemes/Office2007/Blue.xaml" />
                </ResourceDictionary>
          </Page.Resources>
    

    Note that this will affect all controls in the current scope.

    You can also create your own theme ResourceDictionaries and use them with C1Scheduler.

    The best way to customize one of the predefined themes is to include the default theme definition in a custom ResourceDictionary and redefine necessary resources, such as theme brushes, there.

    Note: To ensure all default styles and templates continue to work correctly during customization, it is suggested that the resource keys are not changed from their default settings.
           
    XAML
    Copy Code
    <Page x:Class="C1WPFSchedulerSamples.ThemedSchedulerWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:c1sched="clr-namespace:C1.WPF.Schedule;assembly=C1.WPF.Schedule"
          xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
          xmlns:sys="clr-namespace:System;assembly=mscorlib"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          mc:Ignorable="PresentationOptions"
          xmlns:local="clr-namespace:C1WPFSchedulerSamples"
          Title="Themed Scheduler"
          KeepAlive="True" Name="rootWindow">
          <Page.Resources>
                <ResourceDictionary>
                      <!—-define theme resource dictionary -->
                      <ResourceDictionary x:Key="custom_theme">
                            <!—- include definition of default theme -->
                            <ResourceDictionary.MergedDictionaries>
                                  <ResourceDictionary
                Source="/C1.WPF.Schedule;component/themes/SchedulerThemes/Office2007/Blue.xaml" />
                            </ResourceDictionary.MergedDictionaries>
                            <!—- redefine some resources -->
                            <Thickness x:Key="C1Scheduler_TimeBorder_Thickness">0</Thickness>
                            <sys:Boolean x:Key="C1Scheduler_ShowNavigationPanels">True</sys:Boolean>
                            <Thickness x:Key="C1Scheduler_AllDayAreaBorder_Thickness">
    1px,0,1px,2px</Thickness>
    <SolidColorBrush x:Key="C1Scheduler_AlternateMonth_Brush" Color="#88FFFFFF"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_AllDayArea_Brush" Color="#88FFFFFF"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_Background" Color="#FF5A8ECE"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_Border_Brush" Color="#FF000080"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_WorkHourBrush" Color="GhostWhite"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_WorkHourBorder_Brush" Color="#98FFFFFF"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_WorkHourLightBorder_Brush"
    Color="#C8FFFFFF" PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_FreeHour_Brush" Color="#D2FFFFFF"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_FreeHourBorder_Brush" Color="#98FFFFFF"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_FreeHourLightBorder_Brush"
    Color="#A8FFFFFF" PresentationOptions:Freeze="true"/>
                            <LinearGradientBrush x:Key="C1Scheduler_Day_SelectedBrush" StartPoint="0,1"
    EndPoint="1,0" PresentationOptions:Freeze="true">
                                  <GradientStop Color="WhiteSmoke" Offset="0" />
                                  <GradientStop Color="Navy" Offset="1" />
                            </LinearGradientBrush>
                            <LinearGradientBrush x:Key="C1Scheduler_TimeSlot_SelectedBrush"
    StartPoint="0,0" EndPoint="1,0" PresentationOptions:Freeze="true">
                                  <GradientStop Color="WhiteSmoke" Offset="0" />
                                  <GradientStop Color="Navy" Offset="1" />
                            </LinearGradientBrush>
                            <SolidColorBrush x:Key="C1Scheduler_ControlArea_Brush" Color="#FFE7EFFF"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_ControlAreaLines_Brush"
    Color="#FF000080" PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_ControlAreaText_Brush" Color="Navy"
    PresentationOptions:Freeze="true"/>
                            <RadialGradientBrush x:Key="C1Scheduler_DayHeader_HoverBrush"
    GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="1"
    PresentationOptions:Freeze="true">
                                  <GradientStop Color="#FFF79494" Offset="0" />
                                  <GradientStop Color="Navy" Offset="1" />
                            </RadialGradientBrush>
                            <LinearGradientBrush x:Key="C1Scheduler_DayHeader_Brush" EndPoint="0.5,1"
    StartPoint="0.5,0" SpreadMethod="Pad"
    MappingMode="RelativeToBoundingBox" PresentationOptions:Freeze="true">
                                  <GradientStop Color="#FFB7C3D5" Offset="0"/>
                                  <GradientStop Color="#FF000080" Offset="1"/>
                            </LinearGradientBrush>
                            <SolidColorBrush x:Key="C1Scheduler_DayHeaderText_Brush" Color="White"
    PresentationOptions:Freeze="true"/>
                            <SolidColorBrush x:Key="C1Scheduler_DayHeaderBorder_Brush" Color="#00000000"
    PresentationOptions:Freeze="true"/>
                            <LinearGradientBrush x:Key="C1Scheduler_AppointmentBgMask_Brush"
    StartPoint="0,0" EndPoint="0,1" PresentationOptions:Freeze="true">
                                  <GradientStop Color="#CCFFFFFF" Offset="0" />
                                  <GradientStop Color="#10FFFFFF" Offset="1" />
                            </LinearGradientBrush>
                      </ResourceDictionary>
                </ResourceDictionary>
          </Page.Resources>
    <Grid>
          <!—- set scheduler’s theme to the custom_theme -->
          <c1:C1Scheduler Name="scheduler1" Theme="{StaticResource custom_theme}"
    Background="CornflowerBlue" FontSize="12" FontWeight="Bold"/>
          </Grid>
    </Page>
    

     

    Notice that all of the brush definitions have PresentationOptions:Freeze="true". This approach can be used for better performance.