Hello,
I have a question about Richtextbox DocumentRuler.
The case is as follows..I insert a table with several rows and columns into my document then insert an InlineUIContainer with a custom control in some table cell.
When I try to change the left/right indent of the inserted InlineUIContainer element a null reference exception is thrown.
Here are the exception details:
{System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Windows.Documents.Commands.Styles.Paragraphs.ChangeParagraphStyleCommandBase`2.PreserveStateBeforeExecute(TContext context)
at Telerik.Windows.Documents.Commands.UndoableDocumentCommandBase`1.OnExecuting(DocumentCommandContextBase context)
at Telerik.Windows.Documents.Commands.DocumentCommandBase`1.Execute(DocumentCommandContextBase context)
at Telerik.Windows.Documents.Model.RadDocumentEditor.ChangeParagraphLeftIndent(Double leftIndent)
at Telerik.Windows.Controls.RadRichTextBox.ChangeParagraphLeftIndent(Double leftIndent)
at Telerik.Windows.Controls.RichTextBoxUI.RadRichTextBoxRulerController.SetSeparatorFirstLineIndentAndHangingIndent(Double firstLineIndent, Double hangingIndent)
at Telerik.Windows.Controls.RichTextBoxUI.DocumentRulerBase.LeftIndent_DragCompleted(Object sender, DragCompletedEventArgs e)
at Telerik.Windows.Controls.RichTextBoxUI.RulerThumb.RaiseDragCompleted(Boolean canceled)
at Telerik.Windows.Controls.RichTextBoxUI.RulerThumb.OnLostMouseCapture(MouseEventArgs e)
at System.Windows.Controls.Control.OnLostMouseCapture(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)}
Here is the code of InlineUIContainer addition:
var container = new InlineUIContainer(instrumentItem, uiSize);
DocumentPosition position = editor.Document.CaretPosition;
Paragraph paragraph = new Paragraph();
container.Width = uiSize.Width;
container.Height = uiSize.Height;
paragraph.Inlines.Add(container);
var paragraphBox = position.GetCurrentParagraphBox();
if (paragraphBox != null)
{
editor.Document.Sections.First.Blocks.AddAfter(paragraphBox.AssociatedParagraph, paragraph);
}
else
{
editor.Document.Sections.First.Blocks.Add(paragraph);
}
editor.UpdateEditorLayout();
Thanks!