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

ArgumentNullException when editing items in a “grouped” gridview

5 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paulo
Top achievements
Rank 1
Paulo asked on 18 Dec 2012, 04:21 PM

An ArgumentNullException is thrown when editing items in a “grouped” grid.
It’s easily reproducible with a small WPF application containing the following files:

MainWindow.xaml

<Window x:Class="gridgroupingbug.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel>
        <telerik:RadGridView
                            x:Name="_iniEntriesGrid"
                            ItemsSource="{Binding Path=IniEntryModels}"
                            SelectedItem="{Binding Path=SelectedIniEntry, Mode=TwoWay}"
                            AutoGenerateColumns="False"
                            AutoExpandGroups="True"
                            CanUserInsertRows="True">
            <telerik:RadGridView.GroupDescriptors>
                <telerik:GroupDescriptor Member="Scope" SortDirection="Ascending" />
                <telerik:GroupDescriptor Member="SectionName" SortDirection="Ascending" />
            </telerik:RadGridView.GroupDescriptors>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Scope}" Header="Scope" Width="3*"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=SectionName}" Header="Section" Width="3*"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Key}" Header="Key" Width="4*"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
        <Button Click="AddClicked">AddLine</Button>
    </StackPanel>
</Window>

MainWindow.xaml.cs

using System.Collections.ObjectModel;
using System.Globalization;
using System.Windows;
namespace gridgroupingbug
{
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();
            IniEntryModels = new ObservableCollection<IniEntryModel>();
            _iniEntriesGrid.DataContext = this;
            for (var i = 0; i < 2; i++)
            {
                IniEntryModels.Add(new IniEntryModel
                    {
                        Key = i.ToString(CultureInfo.InvariantCulture),
                        Scope = "MyScope1",
                        SectionName = "SomeSection",
                    });
            }
        }
        public ObservableCollection<IniEntryModel> IniEntryModels { get; private set; }
        private void AddClicked(object sender, RoutedEventArgs e)
        {
            IniEntryModels.Add(new IniEntryModel());
        }
    }
    public class IniEntryModel
    {
        public string Scope { get; set; }
        public string SectionName { get; set; }
        public string Key { get; set; }
    }
}

Telerik version: 2012.3.1129.40

Steps to reproduce:

  1.       Make sure you have at least two levels of grouping set in the grid (in our example, the first two columns)
  2.       Add a new item to the list bound to the grid’s ItemsSource (in our example, IniEntryModel)
  3.       Edit the newly added line (any column)
  4.       Move the focus to somewhere out of the grid (click in the button, for example), and an Exception is thrown.

Exception/Stack Trace:
System.ArgumentNullException was unhandled

  HResult=-2147467261

  Message=Value cannot be null.

Parameter name: element

  Source=Telerik.Windows.Controls

  ParamName=element

  StackTrace:

       at Telerik.Windows.Controls.ParentOfTypeExtensions.<GetParents>d__0.MoveNext() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Extensions\ParentOfTypeExtensions.cs:line 74

       at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()

       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

       at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEdit(UIElement focusedElement) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 1021

       at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEditOnLostFocus() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 899

       at Telerik.Windows.Controls.GridView.GridViewCell.Editor_LostFocus(Object sender, RoutedEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 930

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)

       at System.Windows.Controls.Primitives.TextBoxBase.OnLostFocus(RoutedEventArgs e)

       at System.Windows.UIElement.IsFocused_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)

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

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

       at System.Windows.Controls.TextBox.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.ClearValueCommon(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata)

       at System.Windows.DependencyObject.ClearValue(DependencyPropertyKey key)

       at System.Windows.Input.FocusManager.OnFocusedElementChanged(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.DependencyObject.SetValue(DependencyProperty dp, Object value)

       at System.Windows.Input.FocusManager.SetFocusedElement(DependencyObject element, IInputElement value)

       at System.Windows.Input.KeyboardNavigation.UpdateFocusedElement(DependencyObject focusTarget)

       at System.Windows.FrameworkElement.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)

       at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)

       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

       at System.Windows.Input.InputManager.ProcessStagingArea()

       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

       at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)

       at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)

       at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)

       at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)

       at System.Windows.UIElement.Focus()

       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonDown(MouseButtonEventArgs e)

       at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)

       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)

       at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)

       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)

       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

       at System.Windows.Input.InputManager.ProcessStagingArea()

       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)

       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)

       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at System.Windows.Interop.HwndSource.InputFilterMessage(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.LegacyInvokeImpl(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.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 gridgroupingbug.App.Main() in c:\lixo\gridgroupingbug\obj\Debug\App.g.cs:line 0

       at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException:

Thanks!

PQ.

5 Answers, 1 is accepted

Sort by
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 19 Dec 2012, 09:29 AM
Hello,

This issue has been fixed with some of our internal builds.
Could you please try your scenario with our latest internal build and let me know if the problem persists?
Thank you in advance.

Kind regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paulo
Top achievements
Rank 1
answered on 21 Dec 2012, 04:49 PM
Hi,
Thanks for the reply. Yes, it works fine with the new internal build. Should I wait for the next stable release or is this internal build stable enough to be distributed in my installer?

Thanks,
PQ.
0
Maya
Telerik team
answered on 24 Dec 2012, 07:42 AM
Hi Paulo,

Generally, our internal builds should be stable enough, but still they are not fully tested. They are our way to provide fixes each week. 

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Matthew C
Top achievements
Rank 1
answered on 18 Feb 2013, 11:38 PM
Is there a workaround for this problem?  I have a similar problem happening with RadGridView for Silverlight using 2012 Q3 release.  Downloading the latest dev build has addressed this problem; however, the powers that be have declared "thou shalt not use a development build." 

--Matt
0
Maya
Telerik team
answered on 19 Feb 2013, 07:29 AM
Hello Matthew,

Our official release Q1 2013 is expected to be available in a couple of days. So, my recommendation would be to wait for it since its binaries will contain the fix you need. 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Paulo
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Paulo
Top achievements
Rank 1
Maya
Telerik team
Matthew C
Top achievements
Rank 1
Share this question
or