Example #1
0
        private UIElement CreateGridColumnHeaderContent(int headerIndex)
        {
            var columnCoords = new GridCoordinates(headerIndex, 0);

            var content = new TextBlock()
            {
                Text          = columnCoords.GetStringCoords().Item1,
                TextAlignment = TextAlignment.Center,
            };

            var border = new Border()
            {
                Child           = content,
                BorderThickness = new Thickness(1, 0, 1, 0),
                BorderBrush     = GridSplitterBrush
            };

            border.ContextMenu = new ContextMenu();
            ((FrameworkElement)border.Child).ContextMenu = border.ContextMenu;

            border.ContextMenu.Items.Add(new MenuItem()
            {
                Header           = "Add column",
                Command          = AddColumnCommand,
                CommandParameter = headerIndex
            });

            border.ContextMenu.Items.Add(new MenuItem()
            {
                Header           = "Remove column",
                Command          = RemoveColumnCommand,
                CommandParameter = headerIndex
            });

            return(border);
        }