本文整理汇总了C#中System.DelegateCommand.CanExecute方法的典型用法代码示例。如果您正苦于以下问题:C# DelegateCommand.CanExecute方法的具体用法?C# DelegateCommand.CanExecute怎么用?C# DelegateCommand.CanExecute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DelegateCommand
的用法示例。
在下文中一共展示了DelegateCommand.CanExecute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemListFilterViewModel
public ItemListFilterViewModel(IEventAggregator iEventAggregator, int _numControls)
{
this.iEventAggregator = iEventAggregator;
buttonActions = new string[] { "FILTER_RESET", "FILTER_TYPE", "FILTER_FILES" };
Filter = "";
FilterType = "Contains";
numControls = _numControls;
MoveRightCommand = new DelegateCommand(MoveRight, CanMoveRight);
MoveLeftCommand = new DelegateCommand(MoveLeft, CanMoveLeft);
RemoveLastCharFromFilterCommand = new DelegateCommand(RemoveLastCharFromFilter, CanRemoveLastCharFromFilter);
ResetFiltersCommand = new DelegateCommand(ResetFilters, CanResetFilters);
EventMap = new Dictionary<string, Action>()
{
{"FILTER_MOVE_LEFT", () =>
{
if (MoveLeftCommand.CanExecute())
{
MoveLeftCommand.Execute();
}
}
},
{"FILTER_MOVE_RIGHT", () =>
{
if (MoveRightCommand.CanExecute())
{
MoveRightCommand.Execute();
}
}
},
{"CHAR_BACK", () =>
{
if (RemoveLastCharFromFilterCommand.CanExecute())
{
RemoveLastCharFromFilterCommand.Execute();
}
}
}
};
EventMapParam = new Dictionary<string, Action<string>>()
{
{"CHAR_SELECT", AppendToFilter},
{"VOS_OPTION", (_filterType) =>
{
FilterType = _filterType;
}
}
};
filterViewToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe(
(viewEventArgs) =>
{
EventHandler(viewEventArgs);
}
);
}
示例2: ConstructorWithOnlyExecuteMethodForCanExecuteTest
public void ConstructorWithOnlyExecuteMethodForCanExecuteTest()
{
var command = new DelegateCommand(m_CommandManager,
ExecuteMethod);
Assert.True(command.CanExecute(),
"CanExecute");
}
示例3: Generic_DelegateCommand_Receives_CanExecute_Parameter
public void Generic_DelegateCommand_Receives_CanExecute_Parameter()
{
int canExecuteParameter = 0;
var command = new DelegateCommand<int>(x => { }, x => { canExecuteParameter = x; return true; });
command.CanExecute(66);
Assert.That(canExecuteParameter, Is.EqualTo(66));
}
示例4: CanExecute_ReturnsFalseIfNullParameter_GenericStruct
public void CanExecute_ReturnsFalseIfNullParameter_GenericStruct()
{
MockCommandHandler<int> handler = new MockCommandHandler<int>() { CanExecuteValue = true };
DelegateCommand<int> command = new DelegateCommand<int>(handler.Execute, handler.CanExecute);
Assert.IsFalse(command.CanExecute(null));
}
示例5: CanExecute_ReturnsTrueIfNullParameter_GenericClass
public void CanExecute_ReturnsTrueIfNullParameter_GenericClass()
{
MockCommandHandler<MockArgumentClass> handler = new MockCommandHandler<MockArgumentClass>() { CanExecuteValue = true };
DelegateCommand<MockArgumentClass> command = new DelegateCommand<MockArgumentClass>(handler.Execute, handler.CanExecute);
Assert.IsTrue(command.CanExecute(null));
}
示例6: CanExecute_ReturnsFalseIfIncorrectType_GenericStruct
public void CanExecute_ReturnsFalseIfIncorrectType_GenericStruct()
{
MockCommandHandler<int> handler = new MockCommandHandler<int>() { CanExecuteValue = true };
DelegateCommand<int> command = new DelegateCommand<int>(handler.Execute, handler.CanExecute);
Assert.IsFalse(command.CanExecute(new MockArgumentClass()));
}
示例7: CanExecute_WillReturnFalse_GenericStruct
public void CanExecute_WillReturnFalse_GenericStruct()
{
MockCommandHandler<int> handler = new MockCommandHandler<int>() { CanExecuteValue = false };
DelegateCommand<int> command = new DelegateCommand<int>(handler.Execute, handler.CanExecute);
Assert.IsFalse(command.CanExecute(42));
}
示例8: CanExecute_WillReturnFalse_GenericClass
public void CanExecute_WillReturnFalse_GenericClass()
{
MockCommandHandler<MockArgumentClass> handler = new MockCommandHandler<MockArgumentClass>() { CanExecuteValue = false };
DelegateCommand<MockArgumentClass> command = new DelegateCommand<MockArgumentClass>(handler.Execute, handler.CanExecute);
Assert.IsFalse(command.CanExecute(new MockArgumentClass()));
}
示例9: CanExecute_WillReturnTrue_NonGeneric
public void CanExecute_WillReturnTrue_NonGeneric()
{
MockCommandHandler handler = new MockCommandHandler() { CanExecuteValue = true };
DelegateCommand command = new DelegateCommand(handler.Execute, handler.CanExecute);
Assert.IsTrue(command.CanExecute(new MockArgumentClass()));
}
示例10: CanExecute_PassesArgument_GenericStruct
public void CanExecute_PassesArgument_GenericStruct()
{
MockCommandHandler<int> handler = new MockCommandHandler<int>();
DelegateCommand<int> command = new DelegateCommand<int>(handler.Execute, handler.CanExecute);
command.CanExecute(42);
CollectionAssert.AreEqual(new[] { 42 }, (ICollection)handler.ArgumentList);
}
示例11: CanExecute_PassesArgument_GenericClass
public void CanExecute_PassesArgument_GenericClass()
{
MockCommandHandler<MockArgumentClass> handler = new MockCommandHandler<MockArgumentClass>();
DelegateCommand<MockArgumentClass> command = new DelegateCommand<MockArgumentClass>(handler.Execute, handler.CanExecute);
MockArgumentClass argument = new MockArgumentClass();
command.CanExecute(argument);
CollectionAssert.AreEqual(new[] { argument }, (ICollection)handler.ArgumentList);
}
示例12: CanExecute_CallsCanExecuteMethod_GenericStruct
public void CanExecute_CallsCanExecuteMethod_GenericStruct()
{
MockCommandHandler<int> handler = new MockCommandHandler<int>();
DelegateCommand<int> command = new DelegateCommand<int>(handler.Execute, handler.CanExecute);
Assert.AreEqual(0, handler.CanExecuteCallCount);
command.CanExecute(42);
Assert.AreEqual(1, handler.CanExecuteCallCount);
}
示例13: CanExecute_CallsCanExecuteMethod_GenericClass
public void CanExecute_CallsCanExecuteMethod_GenericClass()
{
MockCommandHandler<MockArgumentClass> handler = new MockCommandHandler<MockArgumentClass>();
DelegateCommand<MockArgumentClass> command = new DelegateCommand<MockArgumentClass>(handler.Execute, handler.CanExecute);
Assert.AreEqual(0, handler.CanExecuteCallCount);
command.CanExecute(new MockArgumentClass());
Assert.AreEqual(1, handler.CanExecuteCallCount);
}
示例14: Default_CanExecute_Returns_True
public void Default_CanExecute_Returns_True()
{
var command = new DelegateCommand(() => { });
Assert.That(command.CanExecute(true));
}
示例15: Calling_CanExecute_Evaluates_Predicate
public void Calling_CanExecute_Evaluates_Predicate(bool predicateResult)
{
var command = new DelegateCommand(() => { }, () => predicateResult);
Assert.That(command.CanExecute(null), Is.EqualTo(predicateResult));
}