當前位置: 首頁>>代碼示例>>C#>>正文


C# DelegateCommand.CanExecute方法代碼示例

本文整理匯總了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);
                }
            );
        }
開發者ID:yousefm87,項目名稱:FilePlayer,代碼行數:59,代碼來源:ItemListFilterViewModel.cs

示例2: ConstructorWithOnlyExecuteMethodForCanExecuteTest

        public void ConstructorWithOnlyExecuteMethodForCanExecuteTest()
        {
            var command = new DelegateCommand(m_CommandManager,
                                              ExecuteMethod);

            Assert.True(command.CanExecute(),
                        "CanExecute");
        }
開發者ID:tschroedter,項目名稱:Selkie.WPF,代碼行數:8,代碼來源:DelegateCommandTests.cs

示例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));
        }
開發者ID:gap777,項目名稱:ViewModelSupport,代碼行數:9,代碼來源:DelegateCommandTests.cs

示例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));
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:7,代碼來源:DelegateCommandFixture.cs

示例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));
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:7,代碼來源:DelegateCommandFixture.cs

示例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()));
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:7,代碼來源:DelegateCommandFixture.cs

示例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));
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:7,代碼來源:DelegateCommandFixture.cs

示例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()));
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:7,代碼來源:DelegateCommandFixture.cs

示例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()));
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:7,代碼來源:DelegateCommandFixture.cs

示例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);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:9,代碼來源:DelegateCommandFixture.cs

示例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);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:10,代碼來源:DelegateCommandFixture.cs

示例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);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:11,代碼來源:DelegateCommandFixture.cs

示例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);
        }
開發者ID:Valks,項目名稱:Okra,代碼行數:11,代碼來源:DelegateCommandFixture.cs

示例14: Default_CanExecute_Returns_True

        public void Default_CanExecute_Returns_True()
        {
            var command = new DelegateCommand(() => { });

            Assert.That(command.CanExecute(true));
        }
開發者ID:gap777,項目名稱:ViewModelSupport,代碼行數:6,代碼來源:DelegateCommandTests.cs

示例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));
        }
開發者ID:gap777,項目名稱:ViewModelSupport,代碼行數:6,代碼來源:DelegateCommandTests.cs


注:本文中的System.DelegateCommand.CanExecute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。