예제 #1
0
        private void AddCustomContextMenuItem()
        {
            DelegateCommand highlightCommand = null;

            Action <object> highlightCommandAction = new Action <object>((parameter) =>
            {
                this.radSpreadsheet.ActiveWorksheetEditor.Selection.Cells.SetFill(highlightFill);
                highlightCommand.InvalidateCanExecute();
            });

            Predicate <object> highlightCommandPredicate = new Predicate <object>((obj) =>
            {
                RadWorksheetEditor editor = this.radSpreadsheet.ActiveWorksheetEditor;
                if (editor != null)
                {
                    PatternFill patternFill = editor.Worksheet.Cells[editor.Selection.ActiveRange.SelectedCellRange].GetFill().Value as PatternFill;
                    if (patternFill != null)
                    {
                        return(!patternFill.Equals(highlightFill));
                    }
                }

                return(false);
            });

            highlightCommand = new SelectionDependentCommand(this.radSpreadsheet, highlightCommandAction, highlightCommandPredicate);

            RadMenuItem newItem = new RadMenuItem();

            newItem.Header  = ContextMenuItemHeader;
            newItem.Command = highlightCommand;

            this.radSpreadsheet.WorksheetEditorContextMenu.Items.Add(newItem);
        }