This is a migrated thread and some comments may be shown as answers.

Setting automatic textforecolor

3 Answers 471 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 09 Jul 2016, 10:51 AM

Hi,

I am using the richtextbox with theming having a dark background. I now would like to permanently set the textforecolor to a light color (like white, depending on the selected dark theme) so that
1.) regular text is displayed with a light forecolor
2.) pasted plain text  is inserted and displayed with a light forecolor
3.) richtext forecolor is changed to a light forecolor
4.) when using the color picker the 'automatic' color is the light forecolor that has been set recently.

what I have so for:

<DockPanel LastChildFill="True">
    <telerik:RadRichTextBoxStatusBar DockPanel.Dock="Bottom" AssociatedRichTextBox="{Binding ElementName=richTextBox}" />
    <telerik:RadRichTextBox x:Name="richTextBox" DockPanel.Dock="Top" 
        Background="{Binding ''}"
        DocumentInheritsDefaultStyleSettings="True"
        Foreground="White"
        FontSize="12"
        IsContextMenuEnabled="True"
        IsSelectionMiniToolBarEnabled="True"
        IsSpellCheckingEnabled="False"
        AcceptsReturn="True"
        AcceptsTab="True" CommandExecuting="richTextBox_CommandExecuting" >
        <telerik:RadRichTextBox.Resources>
            <Style TargetType="{x:Type telerik:DocumentWebLayoutPresenter}">
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style TargetType="{x:Type telerik:DocumentPrintLayoutPresenter}">
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <!--<Style TargetType="telerik:RadRichTextBox">
                <Setter Property="Background" Value="{DynamicResource ContainerBackgroundBrush}" />
            </Style>-->
        </telerik:RadRichTextBox.Resources>
    </telerik:RadRichTextBox>
</DockPanel>

public bool PasteAsPlaneText { get; set; } = true;
 
private void richTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
    if (e.Command is PasteCommand)
    {
        if (PasteAsPlaneText)
        {
            e.Cancel = true;
            this.richTextBox.Insert(Clipboard.GetText());
        }
    }
 }

Until now I couldn't find a way to achieve this. How would I have to proceed to get this szenario implemented? Any example/solution?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Jul 2016, 07:08 AM
Hello Oliver,

I'll go straight to your questions:

To change the default foreground to some light color (e.g. white), you should change the ForeColor property of the RadDocument's default style. In this way, when the user types into RadRichTextBox, or a plain text without any applied style on it is inserted through the clipboard, the foreground would be white. 

In order to change the formatting color picker's automatic color, you should change the corresponding property:
<telerik:FormattingColorPicker ActiveColor="Red" AutomaticColor="White" BorderThickness="0" telerik:ScreenTip.Description="Change the text color."
                       Image="{telerik:IconResource IconRelativePath=16/FontForeColor.png,IconSources={StaticResource IconSources}}"
                       telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding ChangeFontForeColorCommand}"
                       telerik:ScreenTip.Title="Font Color"/>

For your convenience I've created a sample demo project which illustrates the above mentioned approach to change the RadRichTextBox's foreground. You can find it attached.

I hope this is helpful.
If you need further assistance, please get back to us again.

Regards,
Todor
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Oliver
Top achievements
Rank 1
answered on 12 Jul 2016, 11:02 PM

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.

0
Todor
Telerik team
answered on 13 Jul 2016, 09:11 AM
Hello Oliver,

Since the RadDocument Style's ForeColor property is not a dependency property you cannot bind it. This means that you should change it in code-behind.

About changing the automatic color of the FormattingColorPicker in the SelectionMiniToolBar control - you should change its control template and to set the property there. The same applies for the ActiveColor property as well. The default style is 'SelectionMiniToolBarStyle' and it is placed under the Telerik.Windows.Controls.RichTextBoxUI.xaml resource dictionary. More about implicit styles you can read in this help article.

Please get back to us if you have more questions or any feedback.

Regards,
Todor
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
RichTextBox
Asked by
Oliver
Top achievements
Rank 1
Answers by
Todor
Telerik team
Oliver
Top achievements
Rank 1
Share this question
or