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

Set background color at runtime?

1 Answer 113 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Charles Bates
Top achievements
Rank 1
Charles Bates asked on 11 Aug 2010, 02:46 PM
Hello,
I have seen, in other threads, recommendations for setting the RichTextBox's background color at design-time, in xaml.
Is it possible to change the background at runtime (allowing the user to set the background, for example)?
If not, this would seem like a serious limitation.
Thanks for any information...
C. Bates

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 12 Aug 2010, 01:00 PM
Hi Charles Bates,
There are two ways to do this:
  1. Change the default background color in the Presenters' default template to Transparent and then change the background of RadRichTextBox:
    <telerik:RadRichTextBox Name="radRichTextBox">
        <telerik:RadRichTextBox.Resources>
            <Style TargetType="telerik:DocumentWebLayoutPresenter">
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style TargetType="telerik:DocumentPrintLayoutPresenter">
                <Setter Property="Background" Value="Transparent" />
            </Style>
        </telerik:RadRichTextBox.Resources>
    </telerik:RadRichTextBox>
  2. radRichTextBox.Background = new SolidColorBrush(Colors.Yellow);
  3. Modify directly the background color of the active presenter like this:
    ((Control)radRichTextBox.ActiveEditorPresenter).Background = new SolidColorBrush(Colors.Yellow);
I hope this solves your problem.

Kind regards,
Boby
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Charles Bates
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or