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

RadRichText and RadTreeView

2 Answers 87 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Kate
Top achievements
Rank 1
Kate asked on 28 Jul 2010, 03:10 PM
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:

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;
       }
   }
Where is my mistake?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Vesko
Telerik team
answered on 02 Aug 2010, 04:31 PM
Hi Kate,

Thanks for this question.
I was able to reproduce the problem. Fortunately we  were able to fix this issues with in our latest internal build (from last week). This fix will be included in the SP1 which is scheduled for the next week.  If you need this fix earlier, you can temporary use the assemblies from the latest internal build.

If you have any further questions, please don't hesitate to ask.

Kind regards,
Vesko
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
Kate
Top achievements
Rank 1
answered on 03 Aug 2010, 08:42 AM
Thanks a lot! I've just tried the assemblies from your latest internal build and it works well.
We are waiting for SP1.
Tags
RichTextBox
Asked by
Kate
Top achievements
Rank 1
Answers by
Vesko
Telerik team
Kate
Top achievements
Rank 1
Share this question
or