Ok, first part nearly working , thanks.
I allow theme switching, so when switching from a dark theme to a ligth theme the forecolor has to be changed from white to dark/black, otherwise the entered (white) text is not readable.
1.) How to do this the xaml way, I guess I would have to bind the document's style forecolor to a dynamic resource??
This is what I have so far:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows;
using
System.Windows.Media;
using
Telerik.Windows.Controls;
namespace
Notizen.Infrastructure
{
public
enum
Theme
{
Expression_Dark,
Green,
Office2013,
Office_Black,
Office_Blue,
Office__Silver,
VisualStudio2013,
Windows7,
Windows8,
Windows8Touch,
}
public
enum
ColorVariation
{
GreenDark,
GreenLight,
Office2013DarkGrey,
Office2013LightGrey,
Office2013White,
VisualStudio2013Blue,
VisualStudio2013Dark,
VisualStudio2013Light
}
public
static
class
ThemeManager
{
public
static
void
ChangeTheme(Theme theme)
{
ClearResourceDictionary();
switch
(theme)
{
case
Theme.Expression_Dark:
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Expression_Dark;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
//ChangeBackgroundStyle(new SolidColorBrush() { Color = Color.FromArgb(255, 28, 28, 28) });
ChangeBackGroundColor(Color.FromArgb(255, 28, 28, 28));
break
;
case
Theme.Office_Black:
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Black;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
ChangeBackGroundColor(Colors.White);
break
;
case
Theme.Office_Blue:
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Blue;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Blue;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Blue;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Blue;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Blue;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office_Blue;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.Office__Silver:
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office__Silver;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office__Silver;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office__Silver;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office__Silver;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office__Silver;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office__Silver;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.Windows8:
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.Windows8Touch:
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.Windows7:
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows7;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Windows7;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.Office2013:
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.VisualStudio2013:
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.VisualStudio2013;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
break
;
case
Theme.Green:
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Green;component/Themes/System.Windows.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Green;component/Themes/Telerik.Windows.Controls.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Green;component/Themes/Telerik.Windows.Controls.Input.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Green;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Green;component/Themes/Telerik.Windows.Controls.Docking.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"/Telerik.Windows.Themes.Green;c;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
//ChangeThemeVariation(ColorVariation.GreenDark);
break
;
default
:
break
;
}
App.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary() { Source =
new
Uri(uriString:
"pack://application:,,,/Assets/styles.xaml"
, uriKind: UriKind.RelativeOrAbsolute) });
}
public
static
void
ChangeThemeVariation(ColorVariation colorVariation)
{
switch
(colorVariation)
{
case
ColorVariation.GreenDark:
GreenPalette.LoadPreset(GreenPalette.ColorVariation.Dark);
ChangeBackGroundColor(Color.FromArgb(255, 45, 45, 48) );
break
;
case
ColorVariation.GreenLight:
GreenPalette.LoadPreset(GreenPalette.ColorVariation.Light);
ChangeBackGroundColor(Colors.White);
break
;
case
ColorVariation.Office2013DarkGrey:
Office2013Palette.LoadPreset(Office2013Palette.ColorVariation.DarkGray);
ChangeBackGroundColor(Colors.White);
break
;
case
ColorVariation.Office2013LightGrey:
Office2013Palette.LoadPreset(Office2013Palette.ColorVariation.LightGray);
ChangeBackGroundColor(Colors.White);
break
;
case
ColorVariation.Office2013White:
Office2013Palette.LoadPreset(Office2013Palette.ColorVariation.White);
ChangeBackGroundColor(Colors.White);
break
;
case
ColorVariation.VisualStudio2013Blue:
VisualStudio2013Palette.LoadPreset(VisualStudio2013Palette.ColorVariation.Blue);
ChangeBackGroundColor(Colors.White);
break
;
case
ColorVariation.VisualStudio2013Dark:
VisualStudio2013Palette.LoadPreset(VisualStudio2013Palette.ColorVariation.Dark);
ChangeBackGroundColor(Color.FromArgb(255, 45, 45, 48) );
break
;
case
ColorVariation.VisualStudio2013Light:
VisualStudio2013Palette.LoadPreset(VisualStudio2013Palette.ColorVariation.Light);
ChangeBackGroundColor(Colors.White);
break
;
default
:
break
;
}
}
public
static
void
ClearResourceDictionary()
{
App.Current.Resources.MergedDictionaries.Clear();
}
private
static
void
ChangeBackGroundColor(Color color)
{
Application.Current.Resources[
"ContainerBackgroundBrush"
] =
new
SolidColorBrush() { Color = color };
//((SolidColorBrush) Application.Current.Resources["ContainerBackgroundBrush"]).Color = color;
}
private
static
void
ChangeBackgroundStyle(SolidColorBrush color)
{
Style style =
new
Style
{
TargetType =
typeof
(System.Windows.Window)
};
style.Setters.Add(
new
Setter(Label.BackgroundProperty, color));
// Brushes.Aquamarine
Application.Current.Resources[
"ContainerBackgroundStyle"
] =
null
;
Application.Current.Resources[
"ContainerBackgroundStyle"
] = style;
}
}
}
2.) How to change the ActiveColor and AutomaticColor for the inbuilt minitoolbar?
Thanks again for any help.