本文整理汇总了C#中RelayCommand.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# RelayCommand.Execute方法的具体用法?C# RelayCommand.Execute怎么用?C# RelayCommand.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelayCommand
的用法示例。
在下文中一共展示了RelayCommand.Execute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CorrectStringCanBeParsedToEnumType
public void CorrectStringCanBeParsedToEnumType()
{
_enumRelayCommand = new RelayCommand<DummyEnum>(ExecuteFunction, CanExecuteFunction);
_enumRelayCommand.Execute("AnotherValue");
Assert.AreEqual(DummyEnum.AnotherValue, _enumArgument);
}
示例2: CorrectArgumentIsSent
public void CorrectArgumentIsSent()
{
_intRelayCommand = new RelayCommand<int>(ExecuteFunction, CanExecuteFunction);
_intRelayCommand.Execute(1);
Assert.AreEqual(1, _intArgument);
}
示例3: CommandIsExecuted
public void CommandIsExecuted()
{
_relayCommand = new RelayCommand(OnActionCalled);
_relayCommand.Execute(null);
Assert.AreEqual(true, _actionHasBeenCalled);
}
示例4: CarInfoCollection
public CarInfoCollection()
{
Cars = new ObservableCollection<CarInfoViewModel>();
UpdateEntryList = new RelayCommand("Refresh", (p) =>
{
ReloadEntryList();
});
UpdateEntryList.Execute(null);
}
示例5: RelayCommand_Construction_WithoutCanExecuteCanActuallyExecute
public void RelayCommand_Construction_WithoutCanExecuteCanActuallyExecute()
{
var count = 0;
var cmd = new RelayCommand(o => count = (int) o);
if (cmd.CanExecute())
cmd.Execute(15);
Assert.AreEqual(15, count);
}
示例6: ExecuteExecutesTheAction
public void ExecuteExecutesTheAction()
{
var run = false;
var command = new RelayCommand(o => { run = true; });
command.Execute(null);
run.Should().BeTrue();
}
示例7: ExecuteDoesNotExecuteTheActionIfCanExecuteIsFalse
public void ExecuteDoesNotExecuteTheActionIfCanExecuteIsFalse()
{
var run = false;
var command = new RelayCommand(o => { run = true; }, o => false);
command.Execute(null);
run.Should().BeFalse();
}
示例8: WrongTypeThrowsException
public void WrongTypeThrowsException()
{
_intRelayCommand = new RelayCommand<int>(ExecuteFunction, CanExecuteFunction);
_intRelayCommand.Execute(0.0);
}
示例9: IncorrectStringThrowsException
public void IncorrectStringThrowsException()
{
_enumRelayCommand = new RelayCommand<DummyEnum>(ExecuteFunction, CanExecuteFunction);
_enumRelayCommand.Execute("InvalidValue");
}
示例10: AddCommandToService
private void AddCommandToService(OleMenuCommandService service, Guid cmdSet, int cmdId, RelayCommand relayCommand)
{
var commandId = new CommandID(cmdSet, cmdId);
var menuCommand = new OleMenuCommand((sender, args) =>
{
relayCommand.Execute(null);
}, commandId);
menuCommand.BeforeQueryStatus += (sender, args) =>
{
menuCommand.Enabled = relayCommand.CanExecute(null);
};
service.AddCommand(menuCommand);
}