1
Vote

RunCommand method issue

description

Hello,

Thank you very much for this simple an nice WPF extension.
I found an issue on the RunCommand method:

private void RunCommand()
    {
        var command = GetCommand( Element );
        if ( command == null )
            return;

        var parameter = GetCommandParameter( Element );
        var target = GetCommandTarget( Element ) ?? Element;

        if ( command is RoutedCommand )
            ( (RoutedCommand)command ).Execute( parameter, target );
        else
            command.Execute(target);
    }
The problem is that in the last line it should pass the parameter rather than the target variable:
private void RunCommand()
    {
        var command = GetCommand( Element );
        if ( command == null )
            return;

        var parameter = GetCommandParameter( Element );
        var target = GetCommandTarget( Element ) ?? Element;

        if ( command is RoutedCommand )
            ( (RoutedCommand)command ).Execute( parameter, target );
        else
            command.Execute(parameter);
    }
I hope this helps someone.

Thanks.

comments