Maps for WPF and Silverlight Layout and Appearance > C1Maps Theming |
Silverlight themes are a collection of image settings that define the look of a control or controls. The benefit of using themes is that you can apply the theme across several controls in the application, thus providing consistency without having to repeat styling tasks.
When you add the C1Maps control to your project, it appears with the default theme:
You can change this appearance by using one of the built-in themes or by creating your own custom theme. All of the built-in themes are based on WPF Toolkit themes. The built-in themes are described and pictured below. Note that in the images below, a row has been selected to show selected styles:
Full Theme Name |
Appearance |
C1ThemeBureauBlack |
|
C1Blue | |
C1ThemeCosmopolitan |
|
C1ThemeExpressionDark |
|
C1ThemeExpressionLight |
|
C1ThemeOffice2007Black |
|
C1ThemeOffice2007Blue |
|
C1ThemeOffice2007Silver |
|
C1ThemeOffice2010Black |
|
C1ThemeOffice2010Blue |
|
C1ThemeOffice2010Silver |
|
C1ThemeRainierOrange |
|
C1ThemeShinyBlue |
|
C1ThemeWhistlerBlue |
To set an element's theme, use the ApplyTheme method. First add a reference to the theme assembly to your project, and then set the theme in code, like this:
Visual Basic |
Copy Code
|
---|---|
Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded Dim theme As New C1ThemeExpressionDark ' Using ApplyTheme C1Theme.ApplyTheme(LayoutRoot, theme) |
C# |
Copy Code
|
---|---|
private void Window_Loaded(object sender, RoutedEventArgs e) { C1ThemeExpressionDark theme = new C1ThemeExpressionDark(); //Using ApplyTheme C1Theme.ApplyTheme(LayoutRoot, theme); } |
To apply a theme to the entire application, use the System.Windows.ResourceDictionary.MergedDictionaries property. First add a reference to the theme assembly to your project, and then set the theme in code, like this:
Visual Basic |
Copy Code
|
---|---|
Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded Dim theme As New C1ThemeExpressionDark ' Using Merged Dictionaries Application.Current.Resources.MergedDictionaries.Add(C1Theme.GetCurrentThemeResources(theme)) End Sub |
C# |
Copy Code
|
---|---|
private void Window_Loaded(object sender, RoutedEventArgs e) { C1ThemeExpressionDark theme = new C1ThemeExpressionDark(); //Using Merged Dictionaries Application.Current.Resources.MergedDictionaries.Add(C1Theme.GetCurrentThemeResources(theme)); } |
Note that this method works only when you apply a theme for the first time. If you want to switch to another ComponentOne theme, first remove the previous theme from Application.Current.Resources.MergedDictionaries.
You can add any of these themes to the C1Maps controls by declaring the theme around the control in markup. For task-based help about adding a theme to the C1Maps control, see Using C1Maps Themes.