Table.cs null exception

2 posts, 0 answers
  1. Clifford
    Clifford avatar
    25 posts
    Member since:
    Sep 2013

    Posted 05 Dec 2013 Link to this post

    I am getting a null exception when trying to bind a raddocument to a radrichtextbox: {Void RecalculateRowHeights(Telerik.Windows.Documents.Layout.TableLayoutBox, Boolean)}

    Here is the stack trace:

       at Telerik.Windows.Documents.Model.Table.RecalculateRowHeights(TableLayoutBox tableBox, Boolean shouldMeasureCells) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Model\Table.cs:line 960

       at Telerik.Windows.Documents.Layout.TableLayoutBox.MeasureOverride(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\TableLayoutBox.cs:line 278

       at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\LayoutElement.cs:line 929

       at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\LayoutElement.cs:line 832

       at Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverrideInternal(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\SectionLayoutBox.cs:line 473

       at Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverride(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\SectionLayoutBox.cs:line 277

       at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\LayoutElement.cs:line 929

       at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\LayoutElement.cs:line 832

       at Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverrideInternal(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\DocumentLayoutBox.cs:line 184

       at Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverride(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\DocumentLayoutBox.cs:line 138

       at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\LayoutElement.cs:line 929

       at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Layout\LayoutElement.cs:line 832

       at Telerik.Windows.Documents.Model.RadDocument.Measure(SizeF measureSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Model\RadDocument.cs:line 1197

       at Telerik.Windows.Documents.UI.DocumentPrintLayoutPresenter.MeasureOverride(Size availableSize) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\DocumentPrintLayoutPresenter.cs:line 675

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)

       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at System.Windows.ContextLayoutManager.UpdateLayout()

       at System.Windows.UIElement.UpdateLayout()

       at Telerik.Windows.Documents.UI.DocumentPresenterBase.Telerik.Windows.Controls.IDocumentEditorPresenter.UpdateLayout()

       at Telerik.Windows.Controls.RadRichTextBox.<>c__DisplayClass1e.<UpdateEditorLayout>b__1d() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 3728

       at Telerik.Windows.Controls.RadRichTextBox.UpdateEditorLayout(Boolean focusCarret, Boolean updateCaretSize, Boolean async) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 3743

       at Telerik.Windows.Controls.RadRichTextBox.UpdateEditorLayout(Boolean async) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 3704

       at Telerik.Windows.Controls.RadRichTextBox.UpdateEditorLayout() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 3695

       at Telerik.Windows.Controls.RadRichTextBox.document_LayoutModeChanged(Object sender, EventArgs e) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 2312

       at Telerik.Windows.Documents.Model.RadDocument.OnLayoutModeChanged() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Model\RadDocument.cs:line 6681

       at Telerik.Windows.Documents.Model.RadDocument.set_LayoutMode(DocumentLayoutMode value) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\Model\RadDocument.cs:line 265

       at Telerik.Windows.Controls.RadRichTextBox.SynchDocumentMiscProperties() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 2774

       at Telerik.Windows.Controls.RadRichTextBox.set_Document(RadDocument value) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Documents\Core\UI\RadRichTextBox.cs:line 1262

       at NBCU.SAFE.POC.DA.UI.Control.TelerikRadEditorControl.DocumentProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) in C:\TfsProj\MiG4\Architectural Prototype\Modules\NBCU.SAFE.POC.DA\NBCU.SAFE.POC.DA.UI\Control\TelerikRadEditorControl.xaml.cs:line 39

       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)

       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)

       at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)

       at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)

       at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)

       at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)

       at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)

       at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)

       at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)

       at MS.Internal.Data.PropertyPathWorker.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)

       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)

       at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)

       at NBCU.SAFE.POC.DA.UI.ViewModel.ClauseMaintenanceViewModel.OnPropertyChanged(String propertyName) in C:\TfsProj\MiG4\Architectural Prototype\Modules\NBCU.SAFE.POC.DA\NBCU.SAFE.POC.DA.UI\ViewModel\ClauseMaintenanceViewModel.cs:line 106

       at NBCU.SAFE.POC.DA.UI.ViewModel.ClauseMaintenanceViewModel.set_SelectedClauseItem(HierarchyViewModel value) in C:\TfsProj\MiG4\Architectural Prototype\Modules\NBCU.SAFE.POC.DA\NBCU.SAFE.POC.DA.UI\ViewModel\ClauseMaintenanceViewModel

    And this is the code:
    		private RadDocument GetRadDocument(IEnumerable table)
    		{
    			StyleDefinition customTableStyle = new StyleDefinition("MyCustomTableStyle"StyleType.Table);
    			//customTableStyle.SpanProperties.FontSize = _exhibitTableInfo.point_size;
    			//customTableStyle.SpanProperties.FontFamily = new FontFamily(_exhibitTableInfo.typeface);
    			//customTableStyle.SpanProperties.FontWeight = _exhibitTableInfo.col_bold_flag == "Y" ? FontWeights.Bold : FontWeights.Normal;
    			customTableStyle.BasedOnName = RadDocumentDefaultStyles.DefaultTableGridStyleName;
    			StyleDefinition firstRowStyle = new StyleDefinition(StyleType.Table);
    			//firstRowStyle.SpanProperties.FontWeight = _exhibitTableInfo.hdr_bold_flag == "Y" ? FontWeights.Bold : FontWeights.Normal;
    			//if (_exhibitTableInfo.hdr_underlined_flag == "Y") firstRowStyle.SpanProperties.UnderlineDecoration = UnderlineTypes.Line;
    			customTableStyle.ConditionalTableStylesCollection.Add(ConditionalTableStyleTypes.FirstRow, firstRowStyle);
     
    			var radDocument = RadDocumentHelper.GetDefaultDocument();
    			radDocument.StyleRepository.Add(customTableStyle);
    			var radSection = new Section();
    			var radTable = new Table();
    			radTable.Style = customTableStyle;
    			//radTable.Borders = new TableBorders(new Border(Convert.ToSingle(_exhibitTableInfo.cell_border_width), BorderStyle.Single, Colors.Black));
     
    			//var type = GetTypeOfIEnumerable(table);
    			//if (type != null) // probably no records in table, so no data to add to table
    			//{
    			//  properties = type.GetProperties().ToDictionary<PropertyInfo, string>(i => i.Name);
     
    			//  radTable.Rows.Add(GetHeaderRow());
    			//  foreach (var row in table) radTable.Rows.Add(GetDataRow(row));
    			//}
     
    			radDocument.Sections.Add(radSection);
    			radSection.Blocks.Add(new Table());
    			return radDocument;
    		}
    
  2. Clifford
    Clifford avatar
    25 posts
    Member since:
    Sep 2013

    Posted 09 Dec 2013 Link to this post

    Seem to have fixed the problem, but not sure how. Just rebuilt the code, and it worked. Have not done a full line by line comparison.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top