I've just upgraded my project to WPF Studio 2017.1. Wow, what a great update! I love the new Tree Controls and the updated PropertyGrid is lightning fast. After the updgrade to use the 2017.1 version of PropertyGrid, I started seeing two issues I hadn't had with the 2016 version.
In my app, the PropertyGrid is bound to a TreeView control's SelectedItem property via XAML. When a node is expanded for the first time, a background worker makes a service call to populate the node's children and update some properties of the object the node is bound to.
Issue 1) If I expand a previously unexpanded node while the PropertyGrid is bound to it, the following error is thrown:
System.InvalidOperationException occurred
HResult=0x80131509
Message=The calling thread cannot access this object because a different thread owns it.
Source=WindowsBase
StackTrace:
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
at ActiproSoftware.Windows.Controls.Grids.TreeListBox.get_ItemAdapter()
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#4Aj(String #ovd)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#3Aj(Object #xhb, PropertyChangedEventArgs #yhb)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at ActiproSoftware.Windows.ObservableObjectBase.OnPropertyChanged(PropertyChangedEventArgs e)
at ActiproSoftware.Windows.Controls.Grids.PropertyData.PropertyModelBase.OnPropertyChanged(PropertyChangedEventArgs e)
at ActiproSoftware.Windows.Controls.Grids.PropertyData.CachedPropertyModelBase.OnPropertyChanged(PropertyChangedEventArgs e)
at ActiproSoftware.Windows.ObservableObjectBase.NotifyPropertyChanged(String propertyName)
at ActiproSoftware.Windows.Controls.Grids.PropertyData.PropertyModelBase.#QOj()
at ActiproSoftware.Windows.Controls.Grids.PropertyData.PropertyModelBase.Refresh(PropertyRefreshReason reason)
at ActiproSoftware.Windows.Controls.Grids.PropertyData.PropertyDescriptorPropertyModel.OnPropertyValueChanged(Object #xhb, EventArgs #yhb)
at System.ComponentModel.PropertyDescriptor.OnValueChanged(Object component, EventArgs e)
at System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(Object component, EventArgs e)
at System.ComponentModel.ReflectPropertyDescriptor.OnINotifyPropertyChanged(Object component, PropertyChangedEventArgs e)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at SOQLStudio.Organization.NotifyPropertyChanged(String propertyName) in P:\SOQL Studio\SOQL Studio\SOQLStudio\Classes\Organization.vb:line 66
This is a new behavior in the 2017 version. In the 2016 version, it didn't matter if the tree node was selected or not.
Issue 2) I get the following error when I select certain child nodes in the tree. The error is consistant in that it happens with the same nodes, but only a few nodes trigger it (so it's data-related in some way):
System.InvalidOperationException occurred
HResult=0x80131509
Message=Failed to compare two elements in the array.
Source=<Cannot evaluate the exception source>
StackTrace:
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer)
at System.Collections.Generic.List`1.Sort(Int32 index, Int32 count, IComparer`1 comparer)
at ActiproSoftware.Windows.Controls.Grids.PropertyData.DataFactoryBase.SortDataModels(IList`1 models, IDataFactoryRequest request, DataModelSortComparer sortComparer)
at ActiproSoftware.Windows.Controls.Grids.PropertyData.DataFactoryBase.GetDataModels(IDataFactoryRequest request)
at ActiproSoftware.Windows.Controls.Grids.PropertyGridItemAdapter.#TMj(PropertyGrid #gCb, IDataModel #SMj)
at ActiproSoftware.Windows.Controls.Grids.PropertyGridItemAdapter.GetChildren(TreeListBox ownerControl, Object item)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#GM()
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#fBj(Boolean #6zj)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#0Dj()
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.get_IsExpandable()
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#bBj()
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#WDj(#LDj #SDb, Boolean #XDj)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#9Aj(IEnumerable #aBj)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#njb(IEnumerable #Ld, Boolean #BCf)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#rBj(IEnumerable #Ld)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#GM()
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#7Aj(Boolean #Ld, TreeListBoxItemAdapter #6Aj, TreeExpansionKind #GAf, Object #BEf)
at ActiproSoftware.Windows.Controls.Grids.TreeListBox.GetOrCreateTreeNode(TreeNode parentTreeNode, Object item, Boolean allowCreate)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#9Aj(IEnumerable #aBj)
at ActiproSoftware.Windows.Controls.Grids.Primitives.TreeNode.#njb(IEnumerable #Ld, Boolean #BCf)
at ActiproSoftware.Windows.Controls.Grids.TreeListBox.ResetItemsSource()
at ActiproSoftware.Windows.Controls.Grids.TreeListBox.OnRootItemPropertyValueChanged(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, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at ActiproSoftware.Windows.Controls.Grids.TreeListBox.set_RootItem(Object value)
at ActiproSoftware.Windows.Controls.Grids.PropertyGrid.Refresh()
at ActiproSoftware.Windows.Controls.Grids.PropertyGrid.<>c__DisplayClass64_0.<RequestRefresh>b__0()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
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 MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext 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, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, 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.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at SOQLStudio.Application.Main()
Inner Exception 1:
ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Again, this is a new behavior in the 2017 version. I didn't have this problem with the 2016 version of PropertyGrid. And I really don't know where to start with this one.
Any help you can provide with these two issues is greatly appreciated.
Thanks... Rick