Hello,
I have RadGridView and RichTextBox. After selecting new row in grid I load HTML document into RichTextBox. I found situation when after second selection change I always receive an error. Do you have any suggestions what am I doing wrong?
Error:
Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.InvalidCastException: Unable to cast object of type 'Telerik.Windows.Documents.Layout.ParagraphLayoutBox' to type 'Telerik.Windows.Documents.Layout.TableLayoutBox'.
w Telerik.Windows.Documents.Layout.TableRowLayoutBox.MeasureOverride(SizeF availableSize)
w Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize)
w Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize)
w Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.TableLayoutBox.ArrangeOverride(SizeF finalSize)
w Telerik.Windows.Documents.Layout.LayoutElement.ArrangeCore(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.SectionLayoutBox.ArrangeOverride(SizeF finalSize)
w Telerik.Windows.Documents.Layout.LayoutElement.ArrangeCore(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.DocumentLayoutBox.ArrangeTask.ArrangeCallback(Object state)
w System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
w System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
w System.Threading.ThreadPoolWorkQueue.Dispatch()
w System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Code:
I have RadGridView and RichTextBox. After selecting new row in grid I load HTML document into RichTextBox. I found situation when after second selection change I always receive an error. Do you have any suggestions what am I doing wrong?
Error:
Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.InvalidCastException: Unable to cast object of type 'Telerik.Windows.Documents.Layout.ParagraphLayoutBox' to type 'Telerik.Windows.Documents.Layout.TableLayoutBox'.
w Telerik.Windows.Documents.Layout.TableRowLayoutBox.MeasureOverride(SizeF availableSize)
w Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize)
w Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize)
w Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.TableLayoutBox.ArrangeOverride(SizeF finalSize)
w Telerik.Windows.Documents.Layout.LayoutElement.ArrangeCore(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.SectionLayoutBox.ArrangeOverride(SizeF finalSize)
w Telerik.Windows.Documents.Layout.LayoutElement.ArrangeCore(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.LayoutElement.Arrange(RectangleF finalRect)
w Telerik.Windows.Documents.Layout.DocumentLayoutBox.ArrangeTask.ArrangeCallback(Object state)
w System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
w System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
w System.Threading.ThreadPoolWorkQueue.Dispatch()
w System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Code:
void
GetDataCompleted(
string
html)
{
richTextBox.Document = html.Import(html);
richTextBox.ChangeLayoutMode(LayoutMode);
if
(richTextBox.Document.Sections.Count > 0)
richTextBox.ChangeSectionMargin(
new
Telerik.Windows.Documents.Layout.Padding(Margins.left, Margins.top, Margins.right, Margins.bottom));
richTextBox.Background =
new
SolidColorBrush(Background);
richTextBox.Resources =
new
ResourceDictionary();
Style webLayoutStyle =
new
Style(
typeof
(DocumentWebLayoutPresenter));
webLayoutStyle.Setters.Add(
new
Setter(DocumentWebLayoutPresenter.BackgroundProperty, Background));
richTextBox.Resources.Add(
typeof
(DocumentWebLayoutPresenter), webLayoutStyle);
Style printLayoutStyle =
new
Style(
typeof
(DocumentPrintLayoutPresenter));
printLayoutStyle.Setters.Add(
new
Setter(DocumentPrintLayoutPresenter.BackgroundProperty, Background));
richTextBox.Resources.Add(
typeof
(DocumentPrintLayoutPresenter), printLayoutStyle);
richTextBox.UpdateEditorLayout();
}