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

Starter questions

6 Answers 143 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel
Top achievements
Rank 1
Daniel asked on 27 Jul 2010, 04:25 PM
Hi, I'm just getting started using the RadRichTextbox and I have a couple questions (I'm using the latest version Q2 2010 with Silvelight 4)...

I have placed the control in a Navigation Page inside a StackPanel

1. The RichTextBox width doesn't fit in the StackPanel width, I need to hardcode the width else its size is (a lot) bigger than the StackPanel.

2. Tried to set the Background color (which is at "Pink" by default).  And the Background stays white.

3. At Run, when mouse click on the control I do not see the cursor and the RichTextBox seems to be read only.  but when I select multiple text I can start typing. 

Am I doing something wrong?

Here is my XAML:
<Grid x:Name="LayoutRoot">
          
        <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">
  
            <StackPanel x:Name="ContentStackPanel">
  
                <Border BorderThickness="5" BorderBrush="Black" Background="#FFA80000">
                    <telerikDocuments:RadRichTextBox Name="radRichTextBox1" Height="200" Width="400" IsReadOnly="False" Background="#FFE6C0CB">
                    </telerikDocuments:RadRichTextBox>
                </Border>
                  
            </StackPanel>
  
        </ScrollViewer>
    </Grid>


thanks

Daniel

6 Answers, 1 is accepted

Sort by
0
Stephen
Top achievements
Rank 1
answered on 28 Jul 2010, 04:49 AM
Hi Daniel,

I have a few (partial) answers for you.

1.  I've had a few issues with the stack panel, mine was with the vertical bars.  In the end I found a more reliable behaviour using the Grid or the Telerik RadDockPanel as their layout behaviour will automatically stretch to fill the content.  I personally try and avoid using the StackPanel as I've found it can get itself confused a bit with controls that can have a dynamic layout (Telerik or otherwise).  Sometimes of course though it is the best layout container for the job.

If you don't want a horizontal scrollbar to appear you can set the visibility for it to Disabled so that it doesn't appear and will word wrap the rest of the content.  Do this with the following code:
ScrollViewer.HorizontalScrollBarVisibility="Disabled"


2.  I've noticed this as well, again probably because of the stackpanel, the 'text' portion of the control doesn't seem to fill.  If your using Blend you could probably investigate this by copying the control template and having a look at it.

3. This one I can actually answer!  (Sort of)  I found the answer in this forum, but had a 30 second look for it and couldn't see it.  There were two solutions, the one I went for is to call the UpdateEditorControl on the control on its MouseLeftButtonUp and GotFocus events.  If this solution doesn't suit your needs then have a trawl through and you might find an alternative answer your looking for.
0
Daniel
Top achievements
Rank 1
answered on 28 Jul 2010, 01:37 PM
Thanks for your reply Stephen,

Actually, I have solved problem #1 and #3 by removing the ScrollViewer

Everything seems to be fine now, Except for the background color issue.  I really need to be able to set the background color for that control.  I removed the stackPanel as you suggested, and nothing has changed.

I then tried to edit the template in Blend, but what seems to be causing the background to be white is the ContentControl, which setting its background has no effect. :/

Daniel

0
Boby
Telerik team
answered on 29 Jul 2010, 04:52 PM
Hi Daniel,
To change the background color of RadRichTextBox, you have to actually change the Background color in the default style of the presenter you will be using. In case of Flow layout mode this is the DocumentWebLayoutPresenter and in case of Paged layout mode this is the DocumentPrintLayoutPresenter. If you will be using both layout modes you can set both styles.

Here is how this can be done in XAML, where 'Yellow' is the example color:
<telerik:RadRichTextBox>
    <telerik:RadRichTextBox.Resources>
        <Style TargetType="telerik:DocumentWebLayoutPresenter">
            <Setter Property="Background" Value="Yellow"/>
        </Style>
        <Style TargetType="telerik:DocumentPrintLayoutPresenter">
            <Setter Property="Background" Value="Yellow"/>
        </Style>
    </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>


All the best,
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
0
Charles Bates
Top achievements
Rank 1
answered on 09 Aug 2010, 12:28 PM
Hello,
I am interested in this topic, as well.
It seems like it is not possible to change the background at runtime (allowing the user to set the background, for example); is that true?
This would seem like a serious limitation.
Thanks for any information...
C. Bates
0
Boby
Telerik team
answered on 11 Aug 2010, 04:14 PM
Hello Charles Bates,
There are two ways to do this:
  1. Change the default background color of the presenter to be transparent with the code previously posted (by using Transparent instead of Yellow) and than 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);
All the best,
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
0
Charles Bates
Top achievements
Rank 1
answered on 11 Aug 2010, 04:19 PM
Thanks for the reply.
I suspected #2 was available, but wasn't sure how to do it.
Tags
RichTextBox
Asked by
Daniel
Top achievements
Rank 1
Answers by
Stephen
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Boby
Telerik team
Charles Bates
Top achievements
Rank 1
Share this question
or