private ContextMenu PrepareContextMenu() { var keepFirst = CreatePartialSubgroupMenu(minSubgroupSize: 1, maxSubgroupSize: 512, displayLast: false); var keepLast = CreatePartialSubgroupMenu(minSubgroupSize: 1, maxSubgroupSize: 512, displayLast: true); var showAll = new MenuItem("Show All Columns", (s, e) => SetColumnSelector($"0-{_getGroupSize() - 1}")); var fgColor = new MenuItem("Font Color", new[] { new MenuItem("Green", (s, e) => SetForegroundColor(DataHighlightColor.Green)), new MenuItem("Red", (s, e) => SetForegroundColor(DataHighlightColor.Red)), new MenuItem("Blue", (s, e) => SetForegroundColor(DataHighlightColor.Blue)), new MenuItem("None", (s, e) => SetForegroundColor(DataHighlightColor.None)) }); var bgColor = new MenuItem("Background Color", new[] { new MenuItem("Green", (s, e) => SetBackgroundColor(DataHighlightColor.Green)), new MenuItem("Red", (s, e) => SetBackgroundColor(DataHighlightColor.Red)), new MenuItem("Blue", (s, e) => SetBackgroundColor(DataHighlightColor.Blue)), new MenuItem("None", (s, e) => SetBackgroundColor(DataHighlightColor.None)) }); var fitWidth = new MenuItem("Autofit Width", (s, e) => _state.FitWidth(_clickedColumnIndex)); var hideThis = new MenuItem("Hide This", HideColumns); var menuItems = new[] { new MenuItem("Keep First") { Enabled = false } } .Concat(keepFirst) .Append(new MenuItem("-")) .Append(new MenuItem("Keep Last", keepLast)) .Append(showAll) .Append(new MenuItem("-")) .Append(fgColor) .Append(bgColor) .Append(new MenuItem("-")) .Append(fitWidth) .Append(new MenuItem("-")) .Append(hideThis); return(new ContextMenu(menuItems.ToArray())); }