Catel.MVVM.CompositeCommand.UnregisterCommand C# (CSharp) Méthode

UnregisterCommand() public méthode

Unregisters the specified command.
The is null.
public UnregisterCommand ( ICommand command ) : void
command ICommand The command.
Résultat void
        public void UnregisterCommand(ICommand command)
        {
            Argument.IsNotNull("command", command);

            lock (_lock)
            {
                for (var i = _commandInfo.Count - 1; i >= 0; i--)
                {
                    var commandInfo = _commandInfo[i];

                    if (ReferenceEquals(commandInfo.Command, command))
                    {
                        command.CanExecuteChanged -= OnCommandCanExecuteChanged;
                        _commandInfo.RemoveAt(i);

                        Log.Debug("Unregistered command from CompositeCommand");
                    }
                }
            }
        }

Usage Example

            private void OnViewModelClosed(object sender, ViewModelClosedEventArgs e)
            {
                Log.Debug("ViewModel '{0}' is closed, automatically unregistering command from CompositeCommand", ViewModel);

                _compositeCommand.UnregisterCommand(Command);

                ViewModel.Closed -= OnViewModelClosed;
                ViewModel = null;
            }
All Usage Examples Of Catel.MVVM.CompositeCommand::UnregisterCommand