Hello!
I have a problem with using a UserControl that contains RadRichTextBox in RadTreeView HierarchicalDataTemplate.
The error text is:
Строка: 56
Ошибка: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: В экземпляре объекта не задана ссылка на объект.
в Telerik.Windows.Documents.UI.DocumentPresenterBase.get_CaretPosition()
в Telerik.Windows.Documents.UI.DocumentPresenterBase.DoOnCaretLocationChanged()
в Telerik.Windows.Documents.UI.DocumentPresenterBase.<DoOnDocumentChanged>b__1()
It occurs, when I try to set RadRichTextBox Document property:
Where is my mistake?
Thanks!
I have a problem with using a UserControl that contains RadRichTextBox in RadTreeView HierarchicalDataTemplate.
The error text is:
Строка: 56
Ошибка: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: В экземпляре объекта не задана ссылка на объект.
в Telerik.Windows.Documents.UI.DocumentPresenterBase.get_CaretPosition()
в Telerik.Windows.Documents.UI.DocumentPresenterBase.DoOnCaretLocationChanged()
в Telerik.Windows.Documents.UI.DocumentPresenterBase.<DoOnDocumentChanged>b__1()
It occurs, when I try to set RadRichTextBox Document property:
public
partial
class
SilverlightControl1 : UserControl
{
private
RadDocument Document;
public
SilverlightControl1()
{
InitializeComponent();
Loaded += SilverlightControl1_Loaded;
}
void
SilverlightControl1_Loaded(
object
sender, RoutedEventArgs e)
{
this
.LoadSampleDocument();
}
private
void
LoadSampleDocument()
{
if
(
this
.Document ==
null
)
{
this
.Document = CreateFormattedDocument(
"gjfdgldjfgkldfjg"
);
}
radRichTextBox.Document =
this
.Document;
radRichTextBox.UpdateEditorLayout();
}
private
RadDocument CreateFormattedDocument(
string
text)
{
RadDocument document =
new
RadDocument();
document.LayoutMode = DocumentLayoutMode.Flow;
document.SectionDefaultPageMargin =
new
Padding(25);
Telerik.Windows.Documents.Model.Section section =
new
Telerik.Windows.Documents.Model.Section();
document.Sections.Add(section);
Telerik.Windows.Documents.Model.Paragraph currentParagraph =
new
Telerik.Windows.Documents.Model.Paragraph();
currentParagraph.SpacingAfter = 0;
section.Paragraphs.Add(currentParagraph);
string
line = text;
if
(!
string
.IsNullOrEmpty(line))
{
Telerik.Windows.Documents.Model.Span span =
new
Telerik.Windows.Documents.Model.Span(line);
currentParagraph.Inlines.Add(span);
}
return
document;
}
}
Thanks!