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

GridViewHeaderCell Style Exception

1 Answer 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adam Marshall
Top achievements
Rank 1
Adam Marshall asked on 18 Oct 2010, 01:21 AM
Hi,

I am trying to set a global header style, but an exception is thrown when I use the following xaml.

<Style TargetType="{x:Type telerik:GridViewHeaderCell}">            
       <Setter Property="Padding" Value="5,0,5,0" />            
</Style>

If I give the style an x:Key="headerCellStyle", and set HeaderCellStyle="{StaticResource headerCellStyle}" , no exception occurs.
I'm using the .net 4 assemblies.

ex.ToString() "System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at Telerik.Windows.Controls.StyleManager.GetTheme(DependencyObject element)\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.PrepareHeaderCellStyle()\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnNotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.PropertyChangedCallback.Invoke(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)\r\n   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)\r\n   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)\r\n   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.PrepareHeaderCellStyle()\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnNotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.PropertyChangedCallback.Invoke(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)\r\n   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)\r\n   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)\r\n   at System.Windows.FrameworkElement.UpdateStyleProperty()\r\n   at System.Windows.FrameworkElement.OnInitialized(EventArgs e)\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnInitialized(EventArgs e)\r\n   at System.Windows.FrameworkElement.OnVisualParentChanged(DependencyObject oldParent)\r\n   at System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject oldParent)\r\n   at System.Windows.Media.VisualCollection.Add(Visual visual)\r\n   at System.Windows.Controls.UIElementCollection.AddInternal(UIElement element)\r\n   at System.Windows.Controls.VirtualizingPanel.AddInternalChild(UIElement child)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.InsertNewContainer(Int32 childIndex, UIElement container)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateChild(IItemContainerGenerator generator, Size constraint, GridViewColumn column, Int32& childIndex, Size& childSize)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.EnsureColumnHeader(Int32 i, IItemContainerGenerator generator, Size constraint, GridViewColumn column, Size& childSize, List`1 realizedColumnIndices, List`1 realizedColumnDisplayIndices)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.EnsureAtleastOneHeader(IItemContainerGenerator generator, Size constraint, List`1 realizedColumnIndices, List`1 realizedColumnDisplayIndices)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.DetermineRealizedColumnsBlockList(Size constraint)\r\n   at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at Telerik.Windows.Controls.GridView.GridViewRowItem.MeasureOverride(Size constraint)\r\n   at Telerik.Windows.Controls.GridView.GridViewHeaderRow.MeasureOverride(Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.ContextLayoutManager.UpdateLayout()\r\n   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)\r\n   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()\r\n   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)\r\n   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)\r\n   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)"

1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 20 Oct 2010, 09:21 AM
Hello Adam,

Can you please share a little bit more info about grid version you used and also about when this exception occured. I tried to set either implicit or explicit styles for GridViewHeaderCell and I was not able to get the exception you mentioned.

Please check the attached project and if you need any additional information let me know.


Sincerely yours,
Vanya Pavlova
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
Tags
GridView
Asked by
Adam Marshall
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or