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:
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
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:
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.
Telerik by Progress
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:
2.) How to change the ActiveColor and AutomaticColor for the inbuilt minitoolbar?
Thanks again for any help.
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.
Telerik by Progress