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

NullReferenceException

7 Answers 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 20 Nov 2011, 04:34 AM

System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=Telerik.Windows.Data
  StackTrace:
       at Telerik.Windows.Data.DataItemCollection.<SetItemsSource>b__3(NotifyCollectionChangedEventArgs c) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 721
       at Telerik.Windows.Data.DataItemCollection.<>c__DisplayClass18.<BindCollections>b__15(NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 838
       at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\Synchronization\ObservableCollectionManager.cs:line 97
       at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\Synchronization\ObservableCollectionManager.cs:line 86
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\WeakEvents\WeakEvent.cs:line 33
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.ComponentModel.SortDescriptionCollection.OnCollectionChanged(NotifyCollectionChangedAction action)
       at System.ComponentModel.SortDescriptionCollection.ClearItems()
       at System.Collections.ObjectModel.Collection`1.Clear()
       at Telerik.Windows.Data.CollectionHelper.Reset(IEnumerable source, IList target, Func`2 itemConverter) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\CollectionHelper.cs:line 437
       at Telerik.Windows.Data.CollectionHelper.Reset(IEnumerable source, IList target) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\CollectionHelper.cs:line 420
       at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\Synchronization\ObservableCollectionManager.cs:line 119
       at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\Synchronization\ObservableCollectionManager.cs:line 86
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\WeakEvents\WeakEvent.cs:line 33
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\RadObservableCollection.cs:line 149
       at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\ObservableItemCollection.cs:line 91
       at System.Collections.ObjectModel.ObservableCollection`1.ClearItems()
       at Telerik.Windows.Data.RadObservableCollection`1.ClearItems() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\RadObservableCollection.cs:line 240
       at Telerik.Windows.Data.ObservableItemCollection`1.ClearItems() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\ObservableItemCollection.cs:line 82
       at System.Collections.ObjectModel.Collection`1.Clear()
       at Telerik.Windows.Data.DataItemCollection.ClearLocalDescriptors() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 165
       at Telerik.Windows.Data.DataItemCollection.set_CollectionView(QueryableCollectionView value) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 97
       at Telerik.Windows.Data.DataItemCollection.ClearItemsSource() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 937
       at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass18.<Bind>b__17() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 3644
       at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\CursorManager.cs:line 16
       at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 3620
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(Object oldValue, Object newValue) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 3274
       at Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(DependencyObject origin, DependencyPropertyChangedEventArgs args) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\DataControl.cs:line 143
       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.Activate(Object item)
       at System.Windows.Data.BindingExpression.OnDataContextChanged(DependencyObject contextElement)
       at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
       at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
       at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
       at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
       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.TreeWalkHelper.InvalidateTreeDependentProperty(TreeChangeInfo info, DependencyObject d, FrameworkObject& fo, DependencyProperty dp, FrameworkPropertyMetadata fMetadata, Style selfStyle, Style selfThemeStyle, ChildRecord& childRecord, Boolean isChildRecordValid, Boolean hasStyleChanged, Boolean isSelfInheritanceParent)
       at System.Windows.TreeWalkHelper.InvalidateTreeDependentProperties(TreeChangeInfo info, FrameworkElement fe, FrameworkContentElement fce, Style selfStyle, Style selfThemeStyle, ChildRecord& childRecord, Boolean isChildRecordValid, Boolean hasStyleChanged, Boolean isSelfInheritanceParent)
       at System.Windows.FrameworkElement.InvalidateTreeDependentProperties(TreeChangeInfo parentTreeState, Boolean isSelfInheritanceParent)
       at System.Windows.FrameworkElement.OnAncestorChangedInternal(TreeChangeInfo parentTreeState)
       at System.Windows.TreeWalkHelper.OnAncestorChanged(DependencyObject d, TreeChangeInfo info)
       at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d)
       at MS.Internal.PrePostDescendentsWalker`1._VisitNode(DependencyObject d)
       at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe)
       at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d)
       at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)
       at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)
       at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)
       at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d)
       at MS.Internal.PrePostDescendentsWalker`1._VisitNode(DependencyObject d)
       at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe)
       at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d)
       at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)
       at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)
       at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)
       at System.Windows.DescendentsWalker`1._VisitNode(DependencyObject d)
       at MS.Internal.PrePostDescendentsWalker`1._VisitNode(DependencyObject d)
       at System.Windows.DescendentsWalker`1.VisitNode(FrameworkElement fe)
       at System.Windows.DescendentsWalker`1.VisitNode(DependencyObject d)
       at System.Windows.DescendentsWalker`1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)
       at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)
       at System.Windows.DescendentsWalker`1.IterateChildren(DependencyObject d)
       at System.Windows.DescendentsWalker`1.StartWalk(DependencyObject startNode, Boolean skipStartNode)
       at MS.Internal.PrePostDescendentsWalker`1.StartWalk(DependencyObject startNode, Boolean skipStartNode)
       at System.Windows.TreeWalkHelper.InvalidateOnTreeChange(FrameworkElement fe, FrameworkContentElement fce, DependencyObject parent, Boolean isAddOperation)
       at System.Windows.FrameworkElement.OnVisualParentChanged(DependencyObject oldParent)
       at System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject oldParent)
       at System.Windows.Media.Visual.RemoveVisualChild(Visual child)
       at System.Windows.FrameworkElement.set_TemplateChild(UIElement value)
       at System.Windows.StyleHelper.ClearGeneratedSubTree(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, FrameworkTemplate oldFrameworkTemplate)
       at System.Windows.StyleHelper.DoTemplateInvalidations(FrameworkElement feContainer, FrameworkTemplate oldFrameworkTemplate)
       at System.Windows.Controls.ContentPresenter.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       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.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.Controls.ContentPresenter.EnsureTemplate()
       at System.Windows.Controls.ContentPresenter.OnPreApplyTemplate()
       at System.Windows.FrameworkElement.ApplyTemplate()
       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.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, 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, Boolean ignoreSyncCtx)
       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, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       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.Window.ShowHelper(Object booleanBox)
       at System.Windows.Window.Show()
       at System.Windows.Window.ShowDialog()
  InnerException:

7 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 21 Nov 2011, 01:14 AM
i have dialog

<Border Grid.Column="0" Grid.Row="0" BorderThickness="1" BorderBrush="Black">
            <telerik:RadTreeView Name="NavigationTreeView" ItemsSource="{Binding Path=ChildrenView}"
                      SelectedItem="{Binding Path=ActiveItem, Mode=TwoWay}"
                      Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
                 
                <telerik:RadTreeView.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Path=ChildrenView}">
                        <TextBlock FontWeight="Regular" Text="{Binding Path=Name, Converter={StaticResource StubConverter}}" />
                    </HierarchicalDataTemplate>
                </telerik:RadTreeView.ItemTemplate>
            </telerik:RadTreeView>
        </Border>
 
        <ScrollViewer Grid.Column="1" Grid.Row="0" Margin="10,0,0,0" HorizontalScrollBarVisibility="Disabled"  VerticalScrollBarVisibility="Auto">
            <ContentControl Content="{Binding Path=ActiveItem}">
                <ContentControl.Resources>
                    <DataTemplate DataType="{x:Type local:GeneralOptionsViewModel}">
                        <local:GeneralOptionsPanel/>
                    </DataTemplate>
                    <DataTemplate DataType="{x:Type map:MapOptionsViewModel}">
                        <map:MapOptionsPanel/>
                    </DataTemplate>
                    <DataTemplate DataType="{x:Type map:RegionOptionsViewModel}">
                        <map:RegionOptionsPanel/>
                    </DataTemplate>
                </ContentControl.Resources>
            </ContentControl>
        </ScrollViewer>

Following user control (raddridview in it) used in data template crush application when user click other node other than MapOptionsPanel

<UserControl x:Class="AppLication.MapOptionsPanel"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dls="http://www.digitallivingsoftware.com/Presentation"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:local="clr-namespace:Modular.MapView.Implementation"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <DockPanel>
         
        <Grid DockPanel.Dock="Left">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
 
            <!-- THIS GRID RAISE EXCEPTION WHEN USER CLICK OTHER ITEM IN TREEE -->
            <telerik:RadGridView Grid.Row="0" Name="AssetGridView" 
                             ItemsSource="{Binding Path=ChildrenView}" SelectedItem="{Binding Path=Children.Selected}"
                             AutoGenerateColumns="False" CanUserDeleteRows="True" CanUserInsertRows="False" SelectionMode="Single"
                             IsFilteringAllowed="False" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed"
                             ShowGroupPanel="False" IsReadOnly="True">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewMaskedTextBoxColumn Header="Name" DataMemberBinding="{Binding Path=Name}" Width="*" MaxWidth="300"/>
                    <telerik:GridViewMaskedTextBoxColumn Header="North West X" DataMemberBinding="{Binding Path=NorthWestX}" Width="75"/>
                    <telerik:GridViewMaskedTextBoxColumn Header="North West Y" DataMemberBinding="{Binding Path=NorthWestY}" Width="75"/>
                    <telerik:GridViewMaskedTextBoxColumn Header="South East X" DataMemberBinding="{Binding Path=SouthEastX}" Width="75"/>
                    <telerik:GridViewMaskedTextBoxColumn Header="South East Y" DataMemberBinding="{Binding Path=SouthEastY}" Width="75"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
 
            <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Left">
                <Button Content="Add" Margin="5,5,5,0" Command="{Binding AddNewChildCommand}" IsEnabled="{Binding CanAddNewChild}" Width="75" />
                <Button Content="Delete" Margin="0,5,5,0" Command="{Binding RemoveChildCommand}" IsEnabled="{Binding CanRemoveChild}" Width="75" />
            </StackPanel>
        </Grid>
 
    </DockPanel>
</UserControl>

0
Vlad
Telerik team
answered on 21 Nov 2011, 07:53 AM
Hi,

 Can you post the grid version?

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mark
Top achievements
Rank 1
answered on 21 Nov 2011, 08:45 AM
I have v2.0.50727
0
Vlad
Telerik team
answered on 21 Nov 2011, 08:50 AM
Hi,

 I'm afraid that this is not the grid assembly version.

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mark
Top achievements
Rank 1
answered on 21 Nov 2011, 09:05 AM
Sorry, it is 2011.2.920.35
0
Vlad
Telerik team
answered on 21 Nov 2011, 09:18 AM
Hi,

 Please open support ticket and send us an example project where we can reproduce the exception. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Vera
Telerik team
answered on 30 Nov 2011, 11:00 AM
Hello Mark,

I have tested your scenario with our Q3 2011 version and this exception is no longer reproducible.

All the best,
Vera
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Vlad
Telerik team
Vera
Telerik team
Share this question
or