Home Forums WPF controls Xceed DataGrid for WPF How to clear an Observable Collection without an exception

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23606 |

    I’m having a problem that I just can’t seem to figure out. I’m using an ObservableCollection as an ObjectDataProvider for the DataGridControl. My collection is periodically refreshed every ten seconds. The refresh method calls Clear() then adds the new objects using Add(object) . The Add(object) method throws the following exception:

    Message:
    Object reference not set to an instance of an object.”

    Stack:
    at Xceed.Wpf.DataGrid.DataGridCollectionView.AddRawItemInGroup(RawItem rawItem)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.AddRawItemInGroup(IList`1 rawItems)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.AddItem(Int32 startIndex, IList items, Int32 newSourceItemCount)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.ProcessDeferredOperations(List`1 deferredOperations, Boolean processAll)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.ProcessDeferredOperations(Object processAll)
    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.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.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.RunInternal(Window window)
    at System.Windows.Application.Run(Window window)
    at System.Windows.Application.Run()

    The exception is appearing within the DataGridControl, and seems to be in response to the item addition. The occurance rate is sporadic and occurs with different items in the collection. Please any advice you can give would be appreciated.

    Imported from legacy forums. Posted by Sean (had 2427 views)

    Xceed Support
    Member
    Post count: 5658

    Thank you for the bug report….

    We’re gonna take a look at this and come back to you in this thread when we have more details.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 369 views)

    User (Old forums)
    Member
    Post count: 23064

    We have fixed a bug in the DataGridCollectionView where adding items to an empty collection would throw an exception, and it seems from the exception details you’ve posted that you are hitting this bug.

    The fix will be available in the next service release, which should be released next week.

    Imported from legacy forums. Posted by Pascal (had 4206 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.