Home Forums WPF controls Xceed DataGrid for WPF aggrevating PropertyChanged error

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

    I’m experiencing an aggrevating error that I’m hoping someone can explain:

    I have a typical ObjectDataProvider and corresponding DataGridCollectionViewSource defined in my XAML source. The collection view is bound to a DataGridControl and everything works as expected. However, I’ve chosen not to use insertion rows or cell editors and instead use dialog windows for the insertion and editing of data.

    In order to display a dialog window for a new data item, I have a button with a click-handler like so:

    private void AddNewDataItemButton_Click(object sender, RoutedEventArgs e)
    {
    DataGridCollectionView view = // Logic to get view source from resource dictionary

    MyDataItem newDataItem = view.AddNew() as MyDataItem;
    MyDialogWindow window = new MyDialogWindow(newDataItem);
    window.ShowDialog();

    if (window.DialogResult.HasValue && window.DialogResult.Value == true)
    view.EndNew();

    else
    view.CancelNew();
    }

    The new data item is assigned to the Window.DataContext property at construction, the dialog is displayed as expected. The problem is that when the data item’s PropertyChanged event is triggered by the dialog bindings, an ArgumentOutOfBoundsException is thrown. This happens 100% of the time for each and every binding to the data item.

    And this is only true for items generated by the DataGridCollectionView.AddNew() method; if I open an existing data item in a dialog to edit; everything works fine.

    If someone could please help explain this behavior it would really help?

    Imported from legacy forums. Posted by Kennie (had 4514 views)

    Xceed Support
    Member
    Post count: 5658

    Would it be possible for you to post the stack trace you have when the exception is thrown?

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

    User (Old forums)
    Member
    Post count: 23064

    Here is the stack trace as requested. Note that this is for a random property on a random class but it appears that the same stack trace is generated for every property.

    at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
    at System.ThrowHelper.ThrowArgumentOutOfRangeException()
    at System.Collections.Generic.List`1.get_Item(Int32 index)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.ReplaceSourceItem(Int32 oldStartIndex, IList oldItems, Int32 newStartIndex, IList newItems)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.BindingList_ListChanged(Object sender, ListChangedEventArgs e)
    at Xceed.Wpf.DataGrid.DataGridCollectionView.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
    at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
    at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
    at Xceed.Utils.Collections.ListChangedEventManager.OnListChanged(Object sender, ListChangedEventArgs args)
    at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
    at System.ComponentModel.BindingList`1.Child_PropertyChanged(Object sender, PropertyChangedEventArgs e)
    at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
    at SmartFX.Core.Crm.ContactItem.SendPropertyChanged(String propertyName) in C:\…\Crm.designer.cs:line 857

    Imported from legacy forums. Posted by Kennie (had 758 views)

    User (Old forums)
    Member
    Post count: 23064

    And I will also note that I am currently having this issue with classes generated by the LINQ to SQL designer.

    I’ve had this error occur before in other projects, but the current project is using the designer generated classes.

    Imported from legacy forums. Posted by Kennie (had 494 views)

    Xceed Support
    Member
    Post count: 5658

    A ticket has been created for this issue and will be looked into by one of the developers. You will be notified when the issue is resolved.

    Thank you for bringing this to our attention.

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

    Xceed Support
    Member
    Post count: 5658

    We have been unable to reproduce this error. Would it be possible for you to send a small repro application to my attention at support@xceedsoft.com?

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

    User (Old forums)
    Member
    Post count: 23064

    Bump.

    I’m also getting a System.ThrowHelper.ThrowArgumentOutOfRangeException()

    on a object’s PropertyChanged event.

     Here is how I get the exception. I have a collection of entities and when I set the Active property to true I get the exception.

        private void grdProducts_InitializingInsertionRow(object sender, Xceed.Wpf.DataGrid.InitializingInsertionRowEventArgs e)
            {
                Entity entity = (Entity) e.InsertionRow.DataContext;
                entity .Active = true;
           }

     Could it not possibly have something to do with the fact that the item does not exist in the datagrid’s item list yet because it is still in the insertionrow?

       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Xceed.Wpf.DataGrid.DataGridCollectionView.ReplaceSourceItem(Int32 oldStartIndex, IList oldItems, Int32 newStartIndex, IList newItems)
       at Xceed.Wpf.DataGrid.DataGridCollectionView.BindingList_ListChanged(Object sender, ListChangedEventArgs e)
       at Xceed.Wpf.DataGrid.DataGridCollectionView.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at Xceed.Utils.Collections.ListChangedEventManager.OnListChanged(Object sender, ListChangedEventArgs args)
       at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
       at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
       at System.ComponentModel.BindingList`1.Child_PropertyChanged(Object sender, PropertyChangedEventArgs e)
       at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
       at DataBase.DataContexts.Product.SendPropertyChanged(String propertyName) in C:\Work\Programming\Source\BQS\DataBase\DataContexts\BqsDB.designer.cs:line 2567
       at DataBase.DataContexts.Product.set_Active(Nullable`1 value) in C:\Work\Programming\Source\BQS\DataBase\DataContexts\BqsDB.designer.cs:line 2386
       at Administrator.Forms.frmProducts.grdProducts_InitializingInsertionRow(Object sender, InitializingInsertionRowEventArgs e) in C:\Work\Programming\Source\BQS\Administrator\Forms\frmProducts.xaml.cs:line 65
       at Xceed.Wpf.DataGrid.DataGridControl.OnInitializingInsertionRow(InitializingInsertionRowEventArgs e)
       at Xceed.Wpf.DataGrid.DataGridContext.InitializeInsertionRow(InsertionRow insertionRow)
       at Xceed.Wpf.DataGrid.InsertionRow.BeginEdit()
       at Xceed.Wpf.DataGrid.Row.OnCellIsBeingEdited_ClassHandler(Object sender, RoutedEventArgs e)
       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 e)
       at Xceed.Wpf.DataGrid.Cell.OnIsBeingEditedChanged(DependencyObject sender, 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 Xceed.Wpf.DataGrid.Cell.SetIsBeingEdited(Boolean value)
       at Xceed.Wpf.DataGrid.Cell.BeginEdit()
       at Xceed.Wpf.DataGrid.Cell.OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
       at System.Windows.UIElement.OnPreviewMouseLeftButtonDownThunk(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.OnPreviewMouseDownThunk(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)

    Imported from legacy forums. Posted by Tersius (had 839 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m also using the Linq Designer generated classes.

     

    I have also managed to replicate the error with the following code.

    —-

    DataGridCollectionViewSource myViewSource = (DataGridCollectionViewSource)Resources[“cvs_products”];
    DataGridCollectionView view = (DataGridCollectionView)myViewSource.View;

    Product prod = view.AddNew() as Product;
    prod.Active = true;

    Where Product is my Entity

     Update: The error also only occurs when a datagrid’s itemsource property is bound to the source.

    Imported from legacy forums. Posted by Tersius (had 1898 views)

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