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

Beta Issue: 2009 Q3

3 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Agustin Rodriguez
Top achievements
Rank 1
Agustin Rodriguez asked on 29 Oct 2009, 03:43 PM
We just got the latest beta release 2009.3.1023.35 and we are getting a NullReferenceException exception while the grid attempts to apply a header template.

 System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Telerik.Windows.Controls.GridView"
  StackTrace:
       at Telerik.Windows.Controls.GridView.GridViewHeaderCell.OnApplyTemplate() in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewHeaderCell.cs:line 515
       at System.Windows.FrameworkElement.ApplyTemplate()
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureChild(UIElement child, Size constraint) in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 485
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.GenerateChild(IItemContainerGenerator generator, Size constraint, GridViewColumn column, Int32& childIndex, Size& childSize) in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 1015
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.EnsureAtleastOneHeader(IItemContainerGenerator generator, Size constraint, List`1 realizedColumnIndices, List`1 realizedColumnDisplayIndices) in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 831
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.DetermineRealizedColumnsBlockList(Size constraint) in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 786
       at Telerik.Windows.Controls.GridView.GridViewCellsPanel.MeasureOverride(Size constraint) in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewCellsPanel.cs:line 438
       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.ItemsPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
       at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.MeasureOverride(Size constraint) in c:\Builds\WPF_Scrum\GridView_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 5772
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
       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.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       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.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       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.Controls.Control.MeasureOverride(Size constraint)
       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.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.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.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Iti.Ccs.Shell.App.Main() in C:\Users\arodriguez.EN3SOFTWARE\ITI.CCS.AR20091014\Source\Iti.Ccs.Shell\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Oct 2009, 03:47 PM
Hello Agustin,

Can you post a bit more info how to reproduce this? Anything special in the grid declaration/binding?

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Agustin Rodriguez
Top achievements
Rank 1
answered on 29 Oct 2009, 04:31 PM
After a little more time it appears that applying a style to the header template has changed a bit in this new release.  The following style works fine in the previous beta release. (causes the header to display any content associated with the tag property of the column, in this case an icon)

  <Style x:Key="GridViewButtonCellHeader" TargetType="{x:Type telcgv:GridViewHeaderCell}">  
                    <Setter Property="OverridesDefaultStyle" Value="True" /> 
                    <Setter Property="MinWidth" Value="0" /> 
                    <Setter Property="Margin" Value="0" /> 
                    <Setter Property="Padding" Value="0" /> 
                    <Setter Property="Background" Value="Transparent" /> 
                    <Setter Property="BorderBrush" Value="{x:Static Brushes.Transparent}" /> 
                    <Setter Property="BorderThickness" Value="0" /> 
                    <Setter Property="Width" Value="Auto" /> 
                    <Setter Property="IsEnabled" Value="False" /> 
                    <Setter Property="Template">  
                        <Setter.Value> 
                            <ControlTemplate> 
                                <ContentControl Width="12" Height="12"    
                                                ContentTemplate="{Binding RelativeSource={RelativeSource Mode='FindAncestor', AncestorType={x:Type telcgv:GridViewHeaderCell}, AncestorLevel=1}, Path=Column.Tag}" /> 
                            </ControlTemplate> 
                        </Setter.Value> 
                    </Setter> 
                      
                </Style> 

The column that uses this style looks like this...

 <telgv:GridViewColumn IsReadOnly="True" IsSortable="False" IsGroupable="False" IsEnabled="False" IsFilterable="False"   
                                      IsReorderable="False" IsResizable="False" Focusable="False" Background="Gainsboro" Header="{x:Null}" 
                                      CellStyle="{StaticResource GridViewButtonCell}"  HeaderCellStyle="{StaticResource GridViewButtonCellHeader}" 
                                      IsVisible="{Binding RelativeSource={RelativeSource Mode='FindAncestor', AncestorType={x:Type local:GridViewUserControl}, AncestorLevel='1'}, Path=ShowRowItemCommandsProxy}" 
                                      Tag="{Binding Source={StaticResource SaveIconDT}}" >   
                    <telgv:GridViewColumn.CellTemplate> 
                        <DataTemplate> 
                            <Button ContentTemplate="{Binding Source={StaticResource SaveIconDT}}" Width="16" Height="16"   
                                                Command="{Binding RelativeSource={RelativeSource Mode='FindAncestor', AncestorType={x:Type local:GridViewUserControl}, AncestorLevel='1'}, Path=SaveRowItemCommandProxy, BindsDirectlyToSource=true}" 
                                                Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                                ToolTip="Save changes for this item." /> 
                        </DataTemplate> 
                    </telgv:GridViewColumn.CellTemplate> 
                </telgv:GridViewColumn> 

this causes the NullReferenceException metioned before, however if I comment out the Template setter in the style the exception is no longer present.

                <Style x:Key="GridViewButtonCellHeader" TargetType="{x:Type telcgv:GridViewHeaderCell}">  
                    <Setter Property="OverridesDefaultStyle" Value="True" /> 
                    <Setter Property="MinWidth" Value="0" /> 
                    <Setter Property="Margin" Value="0" /> 
                    <Setter Property="Padding" Value="0" /> 
                    <Setter Property="Background" Value="Transparent" /> 
                    <Setter Property="BorderBrush" Value="{x:Static Brushes.Transparent}" /> 
                    <Setter Property="BorderThickness" Value="0" /> 
                    <Setter Property="Width" Value="Auto" /> 
                    <Setter Property="IsEnabled" Value="False" /> 
                    <!--<Setter Property="Template"
                        <Setter.Value> 
                            <ControlTemplate> 
                                <ContentControl Width="12" Height="12"    
                                                ContentTemplate="{Binding RelativeSource={RelativeSource Mode='FindAncestor', AncestorType={x:Type telcgv:GridViewHeaderCell}, AncestorLevel=1}, Path=Column.Tag}" /> 
                            </ControlTemplate> 
                        </Setter.Value> 
                    </Setter>--> 
                      
                </Style> 

Perhaps I need to correct the way the header template is set, or I may be doing it wrong all along?
0
Stefan Dobrev
Telerik team
answered on 03 Nov 2009, 10:08 AM
Hello Agustin,

Thank for reporting this issue. It was introduced in the beta2 and we have already fixed the null reference exception for the official release.

Regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Agustin Rodriguez
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Agustin Rodriguez
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Share this question
or