Home Forums WPF controls Xceed DataGrid for WPF NullReferenceException

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

    Hi,

    I get the following Exception when clicking in a Cell while the CollectionView is refreshing.

    System.NullReferenceException was unhandled
    Message=”Object reference not set to an instance of an object.”
    Source=”Xceed.Wpf.DataGrid”
    StackTrace:
    at Xceed.Wpf.DataGrid.DataGridControl.GetFixedItem(DependencyObject obj)
    at Xceed.Wpf.DataGrid.DataGridControl.GetFixedItemFromContainer(DependencyObject container)
    at Xceed.Wpf.DataGrid.DataGridContext.GetItemFromContainer(DependencyObject container)
    at Xceed.Wpf.DataGrid.Cell.OnGotFocus(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.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
    at System.Windows.DependencyObject.SetValue(DependencyPropertyKey key, Object value)
    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, OperationType operationType)
    at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, 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(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)
    at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
    at System.Windows.UIElement.Focus()
    at Xceed.Wpf.DataGrid.DataGridControl.SetFocusHelper(UIElement item, Cell cell, Boolean forceFocus, Boolean preserveEditorFocus)
    at Xceed.Wpf.DataGrid.DataGridContext.SetCurrent(Object item, Column column, Boolean forceFocus)
    at Xceed.Wpf.DataGrid.Cell.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(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(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, Int32 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, 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) S

    Imported from legacy forums. Posted by Daniel (had 3943 views)

    Xceed Support
    Member
    Post count: 5658

    I have created a ticket for this issue and will post back here after we have investigated the cause.

    Thank you for bringing this to our attention.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 477 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,
    would it be possible to get repro steps or a send a repro app at support@xceedsoft.com mentioning this post to help us inverstigate further.

    Thanks

    Imported from legacy forums. Posted by Chris [Xceed] (had 3184 views)

    User (Old forums)
    Member
    Post count: 23064

    I am also getting the same error when I am editing some values in cell and on lost focus i have written some logic of calculate values. It gives this error after finishing LostFocus event

    Imported from legacy forums. Posted by arya009 (had 437 views)

    Xceed Support
    Member
    Post count: 5658

    Are you using the CollectionView.Filter to do some custom filtering? 

    If you do, this exception can occur when the DataGridControl refreshes because its internal currency manager puts a SetCurrent operation to process on the Dispatcher. If you modify the ItemsSource of the DataGridControl by another mecanism and the CurrentItem is filtered out, this exception is raised.  

     

    If you don’t, can you provide more information on what you are doing?

    Imported from legacy forums. Posted by Chris [Xceed] (had 513 views)

    User (Old forums)
    Member
    Post count: 23064

    I am trying to calculate some value on grid’s Cell Lost focus. It successfully finishes the event and then raises this exception…I have even tried the sample code and modified it and it gives me the same error. I am getting content of current cell and then getting datarow and then setting content of other cell..

    Imported from legacy forums. Posted by arya009 (had 432 views)

    User (Old forums)
    Member
    Post count: 23064

    This is my code..I have modified this in Stats Function sample code….

     

     private void gvStock_CellLostFocus(object sender, RoutedEventArgs e)

        {

            string content = (sender as DataCell).Content.ToString();

            Xceed.Wpf.DataGrid.DataRow dr = grid.GetContainerFromItem(grid.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;

            dr.Cells[9].Content = Convert.ToInt32(content);

        } 

     

    <Style TargetType=”{x:Type xcdg:DataCell}”>

                    <EventSetter Event=”LostFocus” Handler=”gvStock_CellLostFocus” />

    </Style>

     

    Imported from legacy forums. Posted by arya009 (had 543 views)

    User (Old forums)
    Member
    Post count: 23064

    any updates???

     

    i hv observed this gives error when i use DataGridCollectionViewSource as data source and if i use cell lost focus event

    Imported from legacy forums. Posted by arya009 (had 589 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

      In version 2.0, this behavior is not supported. This type of hack is avoided in version 3.0 since some events were added to DataGridCollectionView:

    http://doc.xceedsoft.com/products/XceedWpfDataGrid/Handling_Edit_Events.html

      

    Imported from legacy forums. Posted by Chris [Xceed] (had 1277 views)

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