Exception while clearing PropertyDefinitions

6 posts, 0 answers
  1. Martin
    Martin avatar
    6 posts
    Member since:
    Apr 2009

    Posted 05 Oct 2012 Link to this post

    Hello,







    if I try to clear the PropertyDefinitons Collection via Clear-Method, I get a Specified argument was out of the range of valid values Exception. StackTrace:



       at MS.Internal.Data.IndexedEnumerable.get_Item(Int32 index)



       at MS.Internal.Data.CollectionViewProxy.GetItemAt(Int32 index)



       at System.Windows.Controls.ItemCollection.GetItemAt(Int32 index)



       at System.Windows.Controls.ItemCollection.get_Item(Int32 index)



       at System.Windows.Controls.ItemContainerGenerator.Generator.GenerateNext(Boolean stopAtRealized, Boolean& isNewlyRealized)



       at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.GenerateNext()



       at System.Windows.Controls.Panel.GenerateChildren()



       at System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)



       at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)



       at System.Windows.Controls.ItemContainerGenerator.OnRefresh()



       at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)



       at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)



       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)



       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)



       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)



       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)



       at System.Windows.Controls.ItemCollection.OnViewCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)



       at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)



       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)



       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)



       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)



       at MS.Internal.Data.CollectionViewProxy._OnViewChanged(Object sender, NotifyCollectionChangedEventArgs args)



       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)



       at Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 959



       at Telerik.Windows.Data.QueryableCollectionView.RefreshOverride() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1106



       at Telerik.Windows.Data.QueryableCollectionView.RefreshInternal() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1055



       at Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer() in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1049



       at Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1394



       at Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1340



       at Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1817



       at Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1797



       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) in c:\TB\135\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\WeakEvents\WeakEvent.cs:line 33



       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)



       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)



       at System.Collections.ObjectModel.ObservableCollection`1.ClearItems()



       at System.Collections.ObjectModel.Collection`1.Clear()



       at ChartEditor.Editors.Drawing.PropertyPane.WorkspaceSelectionChanged(Object sender, EventArgs eventArgs) in c:\Users\Martin\Documents\Visual Studio 2012\Projects\ChartEditor\ChartEditor\Editors\Drawing\PropertyPane.xaml.cs:line 33



       at ChartEditor.Workspace.set_SelectedItem(IDrawingItem value) in c:\Users\Martin\Documents\Visual Studio 2012\Projects\ChartEditor\ChartEditor\Workspace.cs:line 142



       at ChartEditor.Editors.Drawing.ItemExplorer.WorkspaceSelectionChanged(Object sender, RoutedPropertyChangedEventArgs`1 e) in c:\Users\Martin\Documents\Visual Studio 2012\Projects\ChartEditor\ChartEditor\Editors\Drawing\ItemExplorer.xaml.cs:line 91



       at System.Windows.RoutedPropertyChangedEventArgs`1.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.RaiseEvent(RoutedEventArgs e)



       at System.Windows.Controls.TreeView.OnSelectedItemChanged(RoutedPropertyChangedEventArgs`1 e)



       at System.Windows.Controls.TreeView.ChangeSelection(Object data, TreeViewItem container, Boolean selected)



       at System.Windows.Controls.TreeViewItem.Select(Boolean selected)



       at System.Windows.Controls.TreeViewItem.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, 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(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, 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.TreeViewItem.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 ChartEditor.App.Main() in c:\Users\Martin\Documents\Visual Studio 2012\Projects\ChartEditor\ChartEditor\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()







    XAML-Declaration:

    <telerik:RadPropertyGrid x:Name="_properties" Item="{Binding Path=Workspace.SelectedItem, ElementName=PropertyPaneControl}" AutoGeneratePropertyDefinitions="False" LabelColumnWidth="Auto" />





    What's my error? The following Workaround works, but the Clear-Method would be nicer:

    // clear properties

    for (int i = _properties.PropertyDefinitions.Count; i > 0; i--)

    _properties.PropertyDefinitions.RemoveAt(i-1);

  2. Ben
    Ben  avatar
    1 posts
    Member since:
    Sep 2012

    Posted 08 Oct 2012 Link to this post

    I also get this error when I clear.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 10 Oct 2012 Link to this post

    Hi,

    I have prepared a simple project to test this scenario on my side, but without any success. Would you please inspect the attachment and point out any differences with your approach?

    Kind regards,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Martin
    Martin avatar
    6 posts
    Member since:
    Apr 2009

    Posted 11 Oct 2012 Link to this post

    Hello,
    at first glance, there are no differences, but I'll continue watching.
  6. Roman
    Roman avatar
    1 posts
    Member since:
    Dec 2011

    Posted 16 Nov 2012 Link to this post

    I do have the same issue. If I call _propertyGrid.PropertyDefinitions.Clear() I get an exception:
    Specified argument was out of the range of valid values.
    Parameter name: index
    --
       at Telerik.Windows.Data.QueryableCollectionView.GetItemAt(Int32 index) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 2166
       at Telerik.Windows.Data.QueryableCollectionView.get_Item(Int32 index) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 289

    As a workaround I can clear it myself, that way it works:
    for (int i = _propertyGrid.PropertyDefinitions.Count -1; i >= 0; i--)
    {
    	_propertyGrid.PropertyDefinitions.RemoveAt(i);
    }
    
    By the way, it would be nice if there would be an event, if the property grid Item would change.
    Then it wouldn't be necesssary to add such code:
    
    	_itemPropertyNotifier = new DependencyPropertyChangeNotifier(_propertyGrid, RadPropertyGrid.ItemProperty);
    	_itemPropertyNotifier.ValueChanged += PropertyGridItemChanged;
    
    
     
    
    
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 21 Nov 2012 Link to this post

    Hello,

    We will introduce such an event in the close future. I will notify you as soon as it is available. Thank you for your feedback.

    Kind regards,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready