本文整理汇总了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;
}
示例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)));
}
}
示例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);
};
}
示例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);
}
示例5: CanExecute
bool CanExecute(RoutedCommand command)
{
TextArea area = this.TextArea;
if (area == null) {
return false;
} else {
return command.CanExecute(null, area);
}
}