RadListBox error when reload

0 Answers 76 Views
ListBox
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Deltaohm asked on 31 Mar 2023, 10:38 AM | edited on 31 Mar 2023, 10:43 AM

Hi,

Maybe I found a strange bug in RadListBox (2023 R1). I guess it is very hard to reply because I use it in a very complex way but maybe you could figure out the cause of problem.
My radlistbox is bound to a ObservableCollection of objects (we can name it List), and it is refreshed every time the user change the tab in raddocking. RadListbox is only one, while tab is multiple. It works in this context.

In my application I can "close the project", operation that implies the reset of every controls in the window, List is now clear, but the instance is still live.
I can "reopen the project" and the original tabs. In this context in many combination of tab open and close I get the following exception:

NsModules.App::AppDomainUnhandledException - System.ArgumentException: An item with the same key has already been added. Key: DeltaOhm.NsModules.Model.NsCursor
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Telerik.Windows.Automation.Peers.RadListBoxAutomationPeer.CreateItemAutomationPeer(Object item)
   at System.Windows.Automation.Peers.ItemsControlAutomationPeer.GetChildrenCore()
   at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
   at System.Windows.Automation.Peers.ItemsControlAutomationPeer.UpdateChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.ContextLayoutManager.fireAutomationEvents()
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   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 MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(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.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at NsModules.App.Main()

I replaced RadListBox with system ListBox and the problem disappeared

Thank you

Luigi

Stenly
Telerik team
commented on 31 Mar 2023, 10:45 AM

Hello Luigi,

Would it be possible to disable the creation of automation peers for the Telerik controls and test the application again? To disable the creation, you could set the AutomationManager.AutomationMode static property to Disabled.

AutomationManager.AutomationMode = AutomationMode.Disabled;

Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 31 Mar 2023, 12:50 PM

Yes,

The problem disappeared with that settings. Side effects?
Thank you

Stenly
Telerik team
commented on 31 Mar 2023, 02:47 PM

The side effect of this suggestion is that the ability to use Coded UI for testing will be lost, as well as the MS Narrator tool or any other end tool that uses automation peers.
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 31 Mar 2023, 03:48 PM

Ok, then is not a problem for me.
Thank you

No answers yet. Maybe you can help?

Tags
ListBox
Asked by
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or