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


C# RelayCommand.CanExecute方法代码示例

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


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

示例1: CanExecuteTest

        public void CanExecuteTest()
        {
            var command = new RelayCommand<string>(p =>
            {
            },
                                                   p => p == "CanExecute");

            Assert.AreEqual(true, command.CanExecute("CanExecute"));
            Assert.AreEqual(false, command.CanExecute("Hello"));
        }
开发者ID:lavige777,项目名称:GalaSoft.MvvmLight,代码行数:10,代码来源:RelayCommandGenericTest.cs

示例2: CanExecuteTest

        public void CanExecuteTest()
        {
            var canExecute = true;

            var command = new RelayCommand(() =>
            {
            },
                                           () => canExecute);

            Assert.AreEqual(true, command.CanExecute(null));

            canExecute = false;

            Assert.AreEqual(false, command.CanExecute(null));
        }
开发者ID:ssickles,项目名称:archive,代码行数:15,代码来源:RelayCommandTest.cs

示例3: CanExecuteTestNull

        public void CanExecuteTestNull()
        {
            var command = new RelayCommand(() =>
            {
            });

            Assert.AreEqual(true, command.CanExecute(null));
        }
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:RelayCommandTest.cs

示例4: CanExecuteTestNull

        public void CanExecuteTestNull()
        {
            var command = new RelayCommand<string>(p =>
            {
            });

            Assert.AreEqual(true, command.CanExecute("Hello"));
        }
开发者ID:lavige777,项目名称:GalaSoft.MvvmLight,代码行数:8,代码来源:RelayCommandGenericTest.cs

示例5: CanExecuteTestInvalidParameterType

        public void CanExecuteTestInvalidParameterType()
        {
            var command = new RelayCommand<string>(p =>
            {
            },
                                                   p => p == "CanExecute");

            command.CanExecute(DateTime.Now);
        }
开发者ID:lavige777,项目名称:GalaSoft.MvvmLight,代码行数:9,代码来源:RelayCommandGenericTest.cs

示例6: CanExecuteTestNullParameter

        public void CanExecuteTestNullParameter()
        {
            var command = new RelayCommand<string>(p =>
            {
            },
                                                   p => false);

            Assert.AreEqual(false, command.CanExecute(null));

            var command2 = new RelayCommand<string>(p =>
            {
            },
                                                   p => true);

            Assert.AreEqual(true, command2.CanExecute(null));
        }
开发者ID:lavige777,项目名称:GalaSoft.MvvmLight,代码行数:16,代码来源:RelayCommandGenericTest.cs

示例7: MainViewModel

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService)
        {
            _dataService = dataService;

            Users = new ObservableCollection<User>();
            ReadAllUsersCommand = new RelayCommand(GetUsers);

            //Execute ReadAllUsersCommand to display all users on the main window when the application launches
            if (ReadAllUsersCommand.CanExecute(null))
                ReadAllUsersCommand.Execute(null);

            SearchUsersCommand = new RelayCommand(SearchUsers);

            SendUserCommand = new RelayCommand(SendUser);

            ReceiveRefreshUsersMessage();
        }
开发者ID:siddhujz,项目名称:PeopleSearch,代码行数:20,代码来源:MainViewModel.cs

示例8: CanExecuteTestInvalidParameterType

        public void CanExecuteTestInvalidParameterType()
        {
            var command = new RelayCommand<string>(
                p =>
                {
                },
                p => p == "CanExecute");

            try
            {
                command.CanExecute(DateTime.Now);
                Assert.Fail("InvalidCastException was not thrown");
            }
            catch (InvalidCastException)
            {
            }
        }
开发者ID:name2name2,项目名称:mvvmlight,代码行数:17,代码来源:RelayCommandGenericTest.cs

示例9: TestCanExecuteWithInvalidParameterType

        public void TestCanExecuteWithInvalidParameterType()
        {
            var command = new RelayCommand<string>(
                p =>
                {
                },
                p => p == "CanExecute");

            var result = command.CanExecute(DateTime.Now);
            Assert.IsFalse(result);
        }
开发者ID:dbremner,项目名称:mvvmlight,代码行数:11,代码来源:RelayCommandGenericTest.cs


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