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