In my situation, I need show available functions, disable functions of ContextMenu on selected ContentPane in menu of my Application.
How to know current ContentPane support what Contextmenu functions are available, disable?
Example:
- When ContentPane is docked in DoucmentHost, available ContextMenu functions of ContentPane is: "Close", "Close All But This", "Floating", "Dockable", "Hide", "New Horizontal Tab Group", "New Vertical Tab Group", disable functions of ContentPane is: "Auto Hide". If only one ContentPane in DocumentHost, "Close All But This", "New Horizontal Tab Group", "New Vertical Tab Group" is not available.
- When ContentPane is docked in SplitPane, available ContextMenu functions of ContentPane is: "Floating", "Tabbed Document", "Auto Hide", "Hide"
- When ContentPane is dockable floating, available ContextMenu functions of ContentPane is: "Floating", "Tabbed Document", "Hide", disable functions is "Auto Hide"
private void ContentPane_OptionsMenuOpening(object sender, Infragistics.Windows.DockManager.Events.PaneOptionsMenuOpeningEventArgs e) { ContentPane cp = e.OriginalSource as ContentPane; List<object> list = new List<object>(); foreach (var item in e.Items) { list.Add(item); } //When ContentPane is floating - disable "AutoHide" if (cp.PaneLocation == PaneLocation.Floating || cp.PaneLocation == PaneLocation.FloatingOnly) { int autoHideIndex = findItemIndex(list, "Auto Hide"); if (autoHideIndex != -1) { MenuItem autoHideItem = e.Items[autoHideIndex] as MenuItem; autoHideItem.IsEnabled = false; } } } private int findItemIndex(List<object> items, string header) { return items.FindIndex(item => item.GetType() == typeof(MenuItem) && (item as MenuItem).Header.Equals(header)); }
Hello Bozhidara Pachilova,
Thank you for your answer and sample. I think I got some ideas from your answer about check location of pane and find menu item index. It is good idea for me in case below request can not do.
I apologize, before my requestion may be not clearly.
Could you show me how to get IsEnable, IsVisible status of ContentPane’s context menu, please? or how to do that.
Example: I want create utility function as below and it will be call at anytime (not from OptionsMenuOpening event)
// input: contentPane: ContentPane owner of context menu need get status // input: context Menu Header. Exp: Floating, Hide, Auto Hide, ... // output: Context menu status (IsEnable,IsVisible) tuple result (bool, bool) getEnableDisableOfContextMenu(ContentPane contentPane, string menuHeader)
Background: I need show in application main menu items: floating, dockable, hide, auto hide, ..that have same visible, enable status of selected ContenPane's context menu items.