Catel.MVVM.CommandManager.UnregisterAction C# (CSharp) Method

UnregisterAction() public method

Unregisters the action with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public UnregisterAction ( string commandName, System.Action action ) : void
commandName string Name of the command.
action System.Action The action.
return void
        public void UnregisterAction(string commandName, Action action)
        {
            Argument.IsNotNullOrWhitespace("commandName", commandName);
            Argument.IsNotNull("action", action);

            if (CatelEnvironment.IsInDesignMode)
            {
                return;
            }

            lock (_lockObject)
            {
                Log.Debug("Unregistering action from '{0}'", commandName);

                if (!_commands.ContainsKey(commandName))
                {
                    throw Log.ErrorAndCreateException<InvalidOperationException>("Command '{0}' is not yet created using the CreateCommand method", commandName);
                }

                _commands[commandName].UnregisterAction(action);

                InvalidateCommands();
            }
        }

Same methods

CommandManager::UnregisterAction ( string commandName, Action action ) : void

Usage Example

Exemplo n.º 1
0
            public void RegisteredActionsCanBeUnregistered_DynamicAction()
            {
                var commandManager = new CommandManager();

                commandManager.CreateCommand("TestAction");

                commandManager.RegisterAction("TestAction", RegisteredActionsCanBeUnregistered_TestMethod);
                commandManager.UnregisterAction("TestAction", RegisteredActionsCanBeUnregistered_TestMethod);

                commandManager.ExecuteCommand("TestAction");

                Assert.IsFalse(_registeredActionsCanBeUnregistered_TestValue);
            }
All Usage Examples Of Catel.MVVM.CommandManager::UnregisterAction