Delete menuitem from dockingmenu

Docking/MDI for WPF Forum

Posted 4 years ago by Marcel
Version: 16.1.0631
Avatar

Hi,

In the 2015 version i can remove a specific menuitem with the following code

            For curPos As Integer = e.ContextMenu.Items.Count - 1 To 0 Step -1
                Dim mnuItem As MenuItem = TryCast(e.ContextMenu.Items(curPos), MenuItem)

                If mnuItem IsNot Nothing Then
                    Dim mnuCmd As RoutedUICommand = CType(mnuItem.Command, RoutedUICommand)

                    If mnuCmd.Name = "MoveToNewHorizontalContainer" Or
                       mnuCmd.Name = "MoveToNewVerticalContainer" Then

                        e.ContextMenu.Items.Remove(mnuItem)
                    End If
                End If
            Next

Now in the 2016 version i cannot use anymore the CType(mnuItem.Command, RoutedUICommand). How I achieve the same in the 2016 version?

Thanks
Marcel

Comments (3)

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marcel,

We no longer use RoutedUICommands since those aren't compatible with UWP and we use the same Docking/MDI codebase in UWP too.

The e.Window will pass you the DockingWindow.  You could check to see if the MenuItem.Command is e.Window.MoveToNewHorizontalContainerCommand, etc.  All the commands used should be exposed on various docking window or tool window properties.


Actipro Software Support

Posted 4 years ago by Marcel
Avatar

Hi,

Thanks, this is what i searched.

Now i missing to commands in the property of the DocumentWindow which i want remove "close all (tab)" and "pin tab". Where i find this two commands to compare with the MenuItem.Command?

Thanks
Marcel

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marcel,

Close All Documents is from DockSite.CloseAllDcoumentsCommand, and Pin Tab is DockingWindow.SetTabbedMdiLayoutKindCommand with a command parameter of TabLayoutKind.Pinned.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 13 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.