Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
900
Dragging nested collapsed row results in Null ref exception
posted

Hi,

I have a very basic example where I bind a data grid to an
IList<Country> Nations {get; set;} property.

The Country class has two collections as properties:
IList<City> Cities { get; set;}
IList<Town> Towns { get; set;}.

I naturally get a nested grid of
Country1
+Cities
+Towns
Country2
+Cities
+Towns

When I drag a collapsed Cities, or Towns row, I immediately get a null reference exception:

 

System.IndexOutOfRangeException:Index was outside the bounds of the array.
   
Stack Trace:

   at Infragistics.Windows.DataPresenter.DataPresenterBase.RecordSelectionEnumerator.GetNextSiblingRecord(Int32 levelIndex, Boolean& retry)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.RecordSelectionEnumerator.GetNextSiblingRecord(Int32 levelIndex, Boolean& retry)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.RecordSelectionEnumerator.GetNextSiblingRecord(Int32 levelIndex, Boolean& retry)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.RecordSelectionEnumerator.MoveNext()
   at Infragistics.Windows.DataPresenter.DataPresenterBase.GetRecordsForSelection(Boolean select, RangeSelectionEvaluator evaluator)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.CalculateSelectionRange(Record record, SelectedItemHolder newSelection, Boolean clearExistingSelection, Boolean select)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.CalculateNewSelectionRange(ISelectableItem item, Boolean clearExistingSelection, Boolean select)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.InternalSelectRange(ISelectableItem item, Boolean clearExistingSelection, Boolean select)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.Infragistics.Windows.Selection.ISelectionHost.SelectRange(ISelectableItem item, Boolean clearExistingSelection)
   at Infragistics.Windows.Selection.SelectionStrategyExtended.OnMouseMove(ISelectableItem item, MouseEventArgs e)
   at Infragistics.Windows.Selection.SelectionController.OnMouseMove(MouseEventArgs e)
   at Infragistics.Windows.Controls.IGControlBase.OnMouseMove(MouseEventArgs e)
   at Infragistics.Windows.DataPresenter.DataPresenterBase.OnMouseMove(MouseEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   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.Input.InputManager.ProcessStagingArea()
   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)
---------------------------------------------------------------------------------------------------------------

Parents
No Data
Reply
  • 17475
    Offline posted

    Hello, 

    Thank you for posting to IG forums! 

    Here I have attached a sample project representing how drag and drop functionality could be used for changing record’s position in hierarchical XamDataGrid. Could you please run the project on your side and let me know whether you get the same error? What is the specific version of Infragistics assemblies you are using? Thank you.

    DragDropRecordsInHierarchy.zip
Children
  • 900
    Offline posted in reply to Maria Tsvyatkova

    Hi Maria,

    Thank you for the example, however the issue is in a different scenario, and a much simpler one.  I have modified your example and was able to repro the exception:

    Using v13.1

    Source:

            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow"
            Height="350"
            Width="525"
            xmlns:igDP="http://infragistics.com/DataPresenter">
       
                        DataSource="{Binding}"/>
       

    using System.Windows;
    using System.Collections.ObjectModel;

    namespace DragDropRecordsInHierarchy
    {
        ///
        /// Interaction logic for MainWindow.xaml
        ///
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();

                Data = new ObservableCollection
                {
                    new Parent
                    {
                        ID = 1,
                        Name = "Parent 1",
                        Children1 = new ObservableCollection
                        {
                            new Child { Age = 15, Name = "Child 1", ParentName = "Parnet 1" },
                            new Child { Age = 11, Name = "Child 2", ParentName = "Parnet 1" },
                            new Child { Age = 2, Name = "Child 3", ParentName = "Parnet 1" },
                        },

                        Children2 = new ObservableCollection
                        {
                            new Child { Age = 15, Name = "Child 1", ParentName = "Parnet 1" },
                            new Child { Age = 11, Name = "Child 2", ParentName = "Parnet 1" },
                            new Child { Age = 2, Name = "Child 3", ParentName = "Parnet 1" },
                        }
                    },
                    new Parent
                    {
                        ID = 2,
                        Name = "Parent 2",
                        Children1 = new ObservableCollection
                        {
                            new Child { Age = 7, Name = "Child 1", ParentName = "Parnet 2" },
                            new Child { Age = 1, Name = "Child 2", ParentName = "Parnet 2" },
                            new Child { Age = 4, Name = "Child 3", ParentName = "Parnet 2" },
                        },

                        Children2 = new ObservableCollection
                        {
                            new Child { Age = 15, Name = "Child 1", ParentName = "Parnet 1" },
                            new Child { Age = 11, Name = "Child 2", ParentName = "Parnet 1" },
                            new Child { Age = 2, Name = "Child 3", ParentName = "Parnet 1" },
                        }
                    },
                    new Parent
                    {
                        ID = 3,
                        Name = "Parent 3",
                        Children1 = new ObservableCollection
                        {
                            new Child { Age = 5, Name = "Child 1", ParentName = "Parnet 3" },
                            new Child { Age = 17, Name = "Child 2", ParentName = "Parnet 3" },
                            new Child { Age = 18, Name = "Child 3", ParentName = "Parnet 3" },
                        },

                        Children2 = new ObservableCollection
                        {
                            new Child { Age = 15, Name = "Child 1", ParentName = "Parnet 1" },
                            new Child { Age = 11, Name = "Child 2", ParentName = "Parnet 1" },
                            new Child { Age = 2, Name = "Child 3", ParentName = "Parnet 1" },
                        }
                    }
                };

                DataContext = Data;
            }

            public ObservableCollection Data { get; set; }
        }


        public class Parent
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public ObservableCollection Children1 { get; set; }
            public ObservableCollection Children2 { get; set; }
        }

        public class Child
        {
            public string Name { get; set; }
            public int Age { get; set; }
            public string ParentName { get; set; }
        }
    }

    The key is the second Child collection.

    When you launch the app, and drag either the collapsed Child1, or Child2 headers, a null ref exception is thrown.