When shutting down our control, we are calling CellWidthResolved to save off some cell information. However, it is throwing an exception. Here is the stack trace:
at System.Windows.Data.BindingExpression.Deactivate()
at System.Windows.Data.BindingExpression.DetachOverride()
at System.Windows.Data.BindingExpressionBase.Detach()
at System.Windows.StyleHelper.ReleaseInstanceDataForTriggerBinding(BindingBase binding, HybridDictionary instanceValues, EventHandler`1 handler)
at System.Windows.StyleHelper.ReleaseInstanceDataForDataTriggers(UncommonField`1 dataField, HybridDictionary instanceValues, Style oldStyle, FrameworkTemplate oldFrameworkTemplate)
at System.Windows.StyleHelper.ReleaseInstanceData(UncommonField`1 dataField, DependencyObject container, FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, FrameworkTemplate oldFrameworkTemplate, InternalFlags hasGeneratedSubTreeFlag)
at System.Windows.StyleHelper.UpdateInstanceData(UncommonField`1 dataField, FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, FrameworkTemplate oldFrameworkTemplate, FrameworkTemplate newFrameworkTemplate, InternalFlags hasGeneratedSubTreeFlag)
at System.Windows.StyleHelper.DoTemplateInvalidations(FrameworkElement feContainer, FrameworkTemplate oldFrameworkTemplate)
at System.Windows.Controls.Control.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at Infragistics.Windows.DataPresenter.RecordPresenter.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at Infragistics.Windows.DataPresenter.DataRecordPresenter.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.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList`1& exclusionContainerDependents, FrugalStructList`1& oldContainerDependents, FrugalStructList`1& newContainerDependents)
at System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle)
at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.FrameworkElement.set_Style(Style value)
at Infragistics.Windows.Helpers.StyleSelectorHelperBase.InvalidateStyle()
at Infragistics.Windows.DataPresenter.RecordPresenter.PrepareContainerForItem(Object item, Boolean isUsedForHeaderOnly)
at Infragistics.Windows.DataPresenter.RecordPresenter.PrepareContainerForItem(Object item)
at Infragistics.Windows.DataPresenter.Internal.TemplateDataRecordCache.InitializeCachedCellArea()
at Infragistics.Windows.DataPresenter.Internal.TemplateDataRecordCache.VerifyCache()
at Infragistics.Windows.DataPresenter.Internal.TemplateDataRecordCache.GetCellValuePresenter(Field field, Boolean createIfNull)
at Infragistics.Windows.DataPresenter.Internal.TemplateDataRecordCache.GetCellValuePresenterDesiredSize(Field field, Size& size)
at Infragistics.Windows.DataPresenter.Internal.TemplateDataRecordCache.GetCellValuePresenterHeight(Field field)
at Infragistics.Windows.DataPresenter.Field.GetDefaultHeight(Boolean isLabel)
at Infragistics.Windows.DataPresenter.Field.GetCellHeightResolvedHelper(Boolean provideDefault)
at Infragistics.Windows.DataPresenter.FieldLayoutItemBase.GetDefaultCellSize(LayoutItemSize size, Field field)
at Infragistics.Windows.DataPresenter.FieldLayoutItem.GetDefaultSize(LayoutItemSize size)
at Infragistics.Windows.DataPresenter.FieldLayoutItem.VerifyVersionImpl(Int32 fieldVersion)
at Infragistics.Windows.DataPresenter.FieldLayoutItem.VerifyVersion()
at Infragistics.Windows.DataPresenter.FieldLayoutItem.GetVisibility()
at Infragistics.Windows.DataPresenter.LayoutItem.Infragistics.Controls.Layouts.Primitives.ILayoutItem.get_Visibility()
at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.GetGridBagCacheHelper(GridBagConstraintCache[]& tmpGccArr)
at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.CalculateGridBagLayout()
at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.CalculatePreferredSize(ILayoutContainer container, Object containerContext)
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.GetTemplateItemSize(Field field, Boolean isHeader)
at Infragistics.Windows.DataPresenter.Field.get_CellWidthResolved()
at RCS.Bengal.UI.MediaLibrary.MediaLibraryControl.<>c__DisplayClass3d.<SetGridColumnCollection>b__37() in C:\RCS_Source\main\Bengal\vs2008\RCS.Bengal.UI\MediaLibrary\MediaLibraryControl.cs:line 1881
I noticed that there is a CellWidthResolvedInteral value, but it’s private. Is there any way to avoid this exception without just placing a try/catch around the call?
Thanks Dan
Hello Dan,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking through your post and I tried to reproduce your behavior, but it seems like everything works ok on my side. If this is still an issue for you and my sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your issue and send it back to for further investigation.
Feel free to write me if you have further questions.
I get this error intermittently. I use the cellwidthresolved property to save the grid's settings to the database so that the users don't have to resize the columns every time. This is what it says in the locals window: field.CellWidthResolved threw an exception of type System.NullReferenceException double {System.NullReferenceException}