All calendar controls use the current system theme, by default. 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:
To set the theme in Microsoft Blend, change the CalendarBase.Theme property at design time:
To set the theme using the ResourceID, use the following XAML:
XAML |
Copy Code
|
---|---|
<my:C1Calendar x:Name="calendar1" MaxSelectionCount="14" Theme="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=my:CalendarBase, ResourceId= MediaPlayer}}"/> |
To set the theme using C1CalendarResources static fields, add the following code to your project:
Visual Basic |
Copy Code
|
---|---|
calendar.Theme = C1CalendarResources.MediaPlayer |
C# |
Copy Code
|
---|---|
calendar.Theme = C1CalendarResources.MediaPlayer; |
To set the theme by defining a ResourceDictionary and DefaultThemeKey in your Page, Window, or Application resources:
XAML |
Copy Code
|
---|---|
<Page.Resources> <ResourceDictionary> <ResourceDictionary x:Key="{x:Static my:CalendarBase.DefaultThemeKey}" Source="/C1.WPF.C1Schedule;component/themes/CalendarThemes/MediaPlayer/MediaPlayer.xaml" /> </ResourceDictionary.MergedDictionaries> </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 the calendar controls.
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.