当前位置: 首页>>代码示例>>C#>>正文


C# RoutedCommand.CanExecute方法代码示例

本文整理汇总了C#中System.Windows.Input.RoutedCommand.CanExecute方法的典型用法代码示例。如果您正苦于以下问题:C# RoutedCommand.CanExecute方法的具体用法?C# RoutedCommand.CanExecute怎么用?C# RoutedCommand.CanExecute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Input.RoutedCommand的用法示例。


在下文中一共展示了RoutedCommand.CanExecute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsEnabled

		bool IsEnabled(RoutedCommand command)
		{
			if (command.CanExecute(null, null))
				return true;
			else if (this.Child != null)
				return command.CanExecute(null, FocusManager.GetFocusedElement(FocusManager.GetFocusScope(this.Child)));
			else
				return false;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:SharpDevelopElementHost.cs

示例2: Run

		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)));
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:8,代码来源:SharpDevelopElementHost.cs

示例3: MapCommand

        public static void MapCommand(ICommand source, RoutedCommand target, UIElement element)
        {
            Contract.Requires(null != source, "source");
            Contract.Requires(null != target, "target");
            Contract.Requires(null != element, "element");

            var binding = new CommandBinding(target,
                (sender, args) => { source.Execute(args.Parameter); },
                (sender, args) => { args.CanExecute = source.CanExecute(args.Parameter); }
            );

            element.CommandBindings.Add(binding);

            source.CanExecuteChanged += (sender, args) =>
            {
                target.CanExecute(null, element);
            };
        }
开发者ID:x-skywalker,项目名称:Tasks.Show,代码行数:18,代码来源:Commands.cs

示例4: EndEdit

        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);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:52,代码来源:DataGrid.cs

示例5: CanExecute

		bool CanExecute(RoutedCommand command)
		{
			TextArea area = this.TextArea;
			if (area == null) {
				return false;
			} else {
				return command.CanExecute(null, area);
			}
		}
开发者ID:chinax01,项目名称:x01.MelonEditor,代码行数:9,代码来源:TextEditor.cs


注:本文中的System.Windows.Input.RoutedCommand.CanExecute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。