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


C# RelayCommand.CanExecute方法代码示例

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


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

示例1: CanExecuteUsesPredicateIfSet

        public void CanExecuteUsesPredicateIfSet()
        {
            var canExecute = false;

            // ReSharper disable once AccessToModifiedClosure
            var command = new RelayCommand(o => { }, o => canExecute);

            command.CanExecute(null).Should().BeFalse();

            canExecute = true;

            command.CanExecute(null).Should().BeTrue();
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:13,代码来源:RelayCommandTest.cs

示例2: RelayCommand_CanExecute_CanNotExecuteWhenFalse

		public void RelayCommand_CanExecute_CanNotExecuteWhenFalse()
		{
			var count = 0;
			var cmd = new RelayCommand(o => count = (int) o, () => false);

			Assert.IsFalse(cmd.CanExecute());
		}
开发者ID:BosslandGmbH,项目名称:Buddy.UI,代码行数:7,代码来源:RelayCommandTests.cs

示例3: RelayCommand_CanExecute_CanExecuteWhenTrue

		public void RelayCommand_CanExecute_CanExecuteWhenTrue()
		{
			var count = 0;
			var cmd = new RelayCommand(o => count = (int) o, () => true);

			Assert.IsTrue(cmd.CanExecute());
		}
开发者ID:BosslandGmbH,项目名称:Buddy.UI,代码行数:7,代码来源:RelayCommandTests.cs

示例4: Given_CanExecuteDelegate_When_ICallCanExecute_ItReturnsCorrectValue

        public void Given_CanExecuteDelegate_When_ICallCanExecute_ItReturnsCorrectValue()
        {
            var expected = new Random().Next(0, 2) == 1;

            var sut = new RelayCommand<object>(Delegate1, o => expected);

            Assert.AreEqual(expected, sut.CanExecute(null));
        }
开发者ID:LionFree,项目名称:Cush,代码行数:8,代码来源:RelayCommandTests.cs

示例5: CanExecuteIsTrueWhenThereIsNoPredicate

        public void CanExecuteIsTrueWhenThereIsNoPredicate()
        {
            _relayCommand = new RelayCommand(OnActionCalled);

            var actual = _relayCommand.CanExecute(null);

            Assert.IsTrue(actual);
        }
开发者ID:MadCowDevelopment,项目名称:Sudoku,代码行数:8,代码来源:RelayCommandTest.cs

示例6: 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);
		}
开发者ID:BosslandGmbH,项目名称:Buddy.UI,代码行数:10,代码来源:RelayCommandTests.cs

示例7: CanExecuteIsTrueIfNotSet

 public void CanExecuteIsTrueIfNotSet()
 {
     var command = new RelayCommand(o => { });
     command.CanExecute(null).Should().BeTrue();
 }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:5,代码来源:RelayCommandTest.cs

示例8: 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);
        }
开发者ID:MBulli,项目名称:SmartCommandlineArgs,代码行数:15,代码来源:Commands.cs

示例9: Given_NoCanExecute_When_AskedForCanExecute_CanExecuteReturnsTrue

 public void Given_NoCanExecute_When_AskedForCanExecute_CanExecuteReturnsTrue()
 {
     var sut = new RelayCommand<object>(Delegate1);
     Assert.IsTrue(sut.CanExecute(null));
 }
开发者ID:LionFree,项目名称:Cush,代码行数:5,代码来源:RelayCommandTests.cs


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