CustomMenuItem submenu disappears after first right-click

I have a docking manager with custom menu items with the following declaration:



<syncfusion:DockingManager.CustomMenuItems>
    <syncfusion:CustomMenuItemCollection>
        <!--Adding custom context menu items-->
        <syncfusion:CustomMenuItem Header="DockMenu 1"/>
        <syncfusion:CustomMenuItem Header="DockMenu 2">


            <!--Adding sub custom context menu items-->
            <syncfusion:CustomMenuItem Header="DockSubMenu 1"/>
            <syncfusion:CustomMenuItem Header="DockSubMenu 2"/>
            <syncfusion:CustomMenuItem Header="DockSubMenu 3" IsChecked="True"/>
        </syncfusion:CustomMenuItem>
    </syncfusion:CustomMenuItemCollection>
</syncfusion:DockingManager.CustomMenu> 


After I right-click the header of a docked window the first time, the second time the submenu no longer has values. See attached video. This is directly from your sample.

Additionally, frequently I also encounter an exception when right-click the header:


System.NullReferenceException: Object reference not set to an instance of an object.

   at Syncfusion.Windows.Tools.Controls.CustomContextMenu.ReSetCustomMenuItem(CustomMenuItemCollection customItemCollection)

   at Syncfusion.Windows.Tools.Controls.CustomContextMenu.OnOpened(RoutedEventArgs e)

   at System.Windows.FrameworkElement.RaiseClrEvent(EventPrivateKey key, EventArgs args)

   at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, 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.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)

   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)

   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)

   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)

   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.SetCurrentValueInternal(DependencyProperty dp, Object value)

   at System.Windows.Controls.PopupControlService.RaiseContextMenuOpeningEvent(IInputElement source, Double x, Double y, Boolean userInitiated)

   at System.Windows.Controls.PopupControlService.ProcessMouseUp(Object sender, MouseButtonEventArgs e)

   at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)

   at System.Windows.Input.InputManager.ProcessStagingArea()

   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 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)




System.InvalidOperationException: Cannot have nested BeginInit calls on the same instance.

   at System.Windows.Controls.ItemsControl.BeginInit()

   at Syncfusion.Windows.Tools.Controls.CustomContextMenu.ReSetCustomMenuItem(CustomMenuItemCollection customItemCollection)

   at Syncfusion.Windows.Tools.Controls.CustomContextMenu.OnOpened(RoutedEventArgs e)

   at System.Windows.FrameworkElement.RaiseClrEvent(EventPrivateKey key, EventArgs args)

   at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, 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.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)

   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)

   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)

   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)

   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.SetCurrentValueInternal(DependencyProperty dp, Object value)

   at System.Windows.Controls.PopupControlService.RaiseContextMenuOpeningEvent(IInputElement source, Double x, Double y, Boolean userInitiated)

   at System.Windows.Controls.PopupControlService.ProcessMouseUp(Object sender, MouseButtonEventArgs e)

   at System.Windows.Controls.PopupControlService.OnPostProcessInput(Object sender, ProcessInputEventArgs e)

   at System.Windows.Input.InputManager.ProcessStagingArea()

   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 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)





Attachment: dockmenu_355bf2c.zip


3 Replies 1 reply marked as answer

KA Karthick Arjunan Syncfusion Team October 10, 2025 09:22 AM UTC

Hi Josepth Badrouk,


Query1: "CustomMenuItem submenu disappears after first right-click"
We have confirmed the reported scenario is a defect and logged a report for the reported scenario, “Submenu items disappear on consecutive context menu interactions in DockingManager”. We will fix this issue and include it in our NuGet release which is scheduled for 28th October 2025.

 

You can track the status of this defect using the following feedback link: Submenu items disappear on consecutive context menu interactions in DockingManager in WPF | Feedback Portal

 

Please let us know if you need any further assistance.

Note: The provided feedback link is private, and you need to log in to view this feedback.

 

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”

 


Query2: "encounter an exception when right-click the header"
We would like to inform you that the NullReferenceException encountered when right-clicking the header multiple times has already been resolved in our latest version 31.1.23, and we were unable to reproduce the InvalidOperationException you mentioned.


For your reference, we’ve attached the tested sample and a demo video demonstrating the behavior in version 31.1.23. We kindly request you to check with this latest version and let us know if the issue persists in your environment.

If you continue to face any difficulties, please feel free to share a reproducible sample or additional details so we can assist you further. We appreciate your cooperation and look forward to resolving this for you.

Regards,
Karthick Arjunan
 


Attachment: DockingManagerDemo_f760edb1.zip


KA Karthick Arjunan Syncfusion Team October 28, 2025 10:17 AM UTC

Hi Josepth Badrouk,

We've resolved the reported issue, and it is now in the testing phase. So, we were not able to include the fix in our latest NuGet (v31.2.4) release, and the fix will be included in our next NuGet release which is scheduled for 4th November 2025. We appreciate your patience until then.

Regards,
Karthick Arjunan



KA Karthick Arjunan Syncfusion Team November 4, 2025 12:58 PM UTC

Hi Josepth Badrouk,

 

We have included the fix for the reported issue “Submenu items disappear on consecutive context menu interactions in DockingManager” in our Weekly NuGet release version 31.2.5 which is available for download ( https://www.nuget.org/).


Root Cause: The disappearance of submenu items in the custom context menu is caused by internal items being cleared during the Unloaded event, without proper reinitialization upon reopening.

 

We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.

Regards,
Karthick Arjunan


Marked as answer
Loader.
Up arrow icon