We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exception after upgrading from Classic

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.


2 Replies 1 reply marked as answer

DH Declan Hillier December 23, 2022 11:16 AM UTC

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.



Marked as answer

HN Harinath Navaneethakrishnan Syncfusion Team December 29, 2022 12:48 PM UTC

Hi Declan,


We are glad that you resolved the issue yourself. However, we were not able to reproduce the issue that you reported in SplitButton control.


We have created a sample based on your requirement. please provide more details about the requirement,
or modify our sample and revert to us with a reproducible issue. So, it will be helpful to prompt the solution further.



Regards,

Harinath N


Attachment: SplitButtonWPF_f0e046ce.zip

Loader.
Up arrow icon