void Run(RoutedCommand command)
		{
			if (command.CanExecute(null, null)) {
				command.Execute(null, null);
			} else if (this.Child != null) {
				command.Execute(null, FocusManager.GetFocusedElement(FocusManager.GetFocusScope(this.Child)));
			}
		}
Пример #2
0
        private bool EndEdit(RoutedCommand command, DataGridCell cellContainer, DataGridEditingUnit editingUnit, bool exitEditMode)
        {
            bool cellLeftEditingMode = true;
            bool rowLeftEditingMode = true;

            if (cellContainer != null)
            {
                if (command.CanExecute(editingUnit, cellContainer))
                {
                    command.Execute(editingUnit, cellContainer);
                }

                cellLeftEditingMode = !cellContainer.IsEditing;
                rowLeftEditingMode = !IsEditingRowItem && !IsAddingNewItem;
            }

            if (!exitEditMode)
            {
                if (editingUnit == DataGridEditingUnit.Cell)
                {
                    if (cellContainer != null)
                    {
                        if (cellLeftEditingMode)
                        {
                            return BeginEdit(null);
                        }
                    }
                    else
                    {
                        // A cell was not placed in edit mode
                        return false;
                    }
                }
                else
                {
                    if (rowLeftEditingMode)
                    {
                        object rowItem = cellContainer.RowDataItem;
                        if (rowItem != null)
                        {
                            EditRowItem(rowItem);
                            return IsEditingRowItem;
                        }
                    }

                    // A row item was not placed in edit mode
                    return false;
                }
            }

            return cellLeftEditingMode && ((editingUnit == DataGridEditingUnit.Cell) || rowLeftEditingMode);
        }
        private Boolean SetColor(Object color, RoutedCommand cmd)
        {
            RichTextBox editor = this.CurrentEditor;

            Color? newColor = null;

            if (color is PropertyInfo)
            {
                newColor = ((PropertyInfo)color).GetValue(null) as Color?;
            }
            else if (color is Color)
            {
                newColor = (Color)color;
            }
            else
            {
                throw new ArgumentException("color");
            }

            if (cmd != null && editor != null && newColor != null)
            {
                cmd.Execute(
                    (Color)newColor, editor);

                editor.Focus();
                this.IsOverflowOpen = false;

                return true;
            }

            return false;
        }
Пример #4
0
		void Execute(RoutedCommand command)
		{
			TextArea textArea = this.TextArea;
			if (textArea != null) {
				command.Execute(null, textArea);
			}
		}