- There are extra spaces at the end of the displayed text, which take on the formatting of the last span of text, but which can't be erased, and the mouse cursor can't be placed into it.
- If the user places the cursor at the end and starts typing, the first letter is appended to the end of the text, but the cursor then jumps to the beginning of the text and subsequent characteres are added to the beginning unless the user stops typing and puts the cursor back at the end.
- It's impossible to select the first character of the text.
These issues make it difficult to work with the control. It's worth noting that I don't see these issues when starting with a blank document in the control and letting the user type, it only seems to happen when I programmtically set the content. I've looked at the InlineCollection and the spans all seem to be identical, so I'm thinking it's possible there's something different on the control itself or the document that is not the same.
There's so much code associated with the control that I can't really share what I have, but I can share some snippets. Here is the declaration of the control in XAML:
<!-- MESSAGE TEXT BOX -->
<telerik:RadRichTextBox x:Name=
"RichText1"
Grid.Row=
"5"
Grid.Column=
"1"
BorderBrush=
"{Binding Path=BorderBrush, ElementName=tbShortName}"
BorderThickness=
"1"
Loaded=
"RichText1_Loaded"
HorizontalAlignment=
"Stretch"
Height=
"185"
KeyDown=
"RichText1_KeyDown"
Margin=
"5"
HorizontalScrollBarVisibility=
"Hidden"
CurrentSpanStyleChanged=
"RichText1_CurrentSpanStyleChanged"
>
</telerik:RadRichTextBox>
This is the what happens after the screen is loaded:
private
void
CreateRichTextDocument()
{
RichText1.Document =
new
RadDocument();
RichText1.Document.LayoutMode = DocumentLayoutMode.Paged;
RichText1.Document.SectionDefaultPageMargin =
new
Padding(5);
RichText1.Document.DefaultPageLayoutSettings.Height = 140;
RichText1.Document.DefaultPageLayoutSettings.Width = 300;
if
(RichText1.Document.Sections.Count == 0) { RichText1.Document.Sections.Add(
new
Section()); }
if
(RichText1.Document.Sections.First.Blocks.Count == 0) { RichText1.Document.Sections.First.Blocks.Add(
new
Paragraph()); }
_messageParagraph = RichText1.Document.Sections.First.Blocks.First
as
Paragraph;
_messageParagraph.SpacingAfter = 0;
Left_Click(
null
,
null
);
// default to left-justified
}
Basically, I'm using the Paged mode, then creating a Section, then a Pagragraph underneath that. I set SpacingAfter to 0 to try to eliminate the space problem mentioned above, but it didn't completely work (although it seemed better).
Any help would be appreciated.