I have an application which was originally implemented using your Classic WPF suite. I'm trying to upgrade it to use your current set, build 20.3.0.61. However, whenever I close the application by clicking the X button I get the following error:-
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
Stack Trace is :-
at System.Windows.Controls.ItemCollection.Clear()
at Syncfusion.Windows.Tools.Controls.SplitButton.Dispose()
at Syncfusion.Windows.Tools.Controls.QuickAccessToolBar.Dispose(Boolean disposing)
at Syncfusion.Windows.Tools.Controls.QuickAccessToolBar.Dispose()
at Syncfusion.Windows.Tools.Controls.Ribbon.Dispose()
at Syncfusion.Windows.Tools.Controls.Ribbon.RootWindow_Closed(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Window.OnClosed(EventArgs e)
at Syncfusion.Windows.Tools.Controls.RibbonWindow.OnClosed(EventArgs e)at System.Windows.Window.WmDestroy()
at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(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)
I'm afraid the application is far too big to attach so I'm hoping the above will give a clue as to what's happening.
Any ideas how I can resolve this?
I'm happy to provide any further information that might help.
Managed to solve it. I noticed that the docs seem to be pushing SplitButtonAdv rather than SplitButton and that the way you data bind is different. We had a SplitButton with an item source:-
<sf:SplitButton Command="{x:Static local:AquatorCommands.ShowIDE}" ItemsSource="{Binding MacroMenuItems}" Label="" LargeIcon="..\Images\vba32x32.png" SmallIcon="..\Images\vba16x16.png" ToolTip="VBA IDE/Macros" VerticalAlignment="Center"/>
I replaced this with a SplitButtonAdv:-
<sf:SplitButtonAdv Command="{x:Static local:AquatorCommands.ShowIDE}" Label="" LargeIcon="..\Images\vba32x32.png" SmallIcon="..\Images\vba16x16.png" ToolTip="VBA IDE/Macros" VerticalAlignment="Center">
<sf:DropDownMenuGroup ItemsSource="{Binding MacroMenuItems}">
<sf:DropDownMenuGroup.ItemTemplate>
<DataTemplate>
<sf:DropDownMenuItem Header="{Binding Header}"/>
</DataTemplate>
</sf:DropDownMenuGroup.ItemTemplate>
</sf:DropDownMenuGroup>
</sf:SplitButtonAdv>
That seems to have fixed the problem. Notably, there's a bunch of other SplitButtons without Item Sources which don't seem to be causing any problems.
So it looks to me like the dispose code of SplitButton doesn't operate on the ItemSource safely.
Hi Declan,
Regards,
Harinath N