sskodje / wpfchrometabs-mvvm

A tab control based on WPF chrome tabs, modified to work with the MVVM pattern
MIT License
256 stars 60 forks source link

AddTabCommand ignores CanExecute of ICommand #9

Closed Revsol closed 8 years ago

sskodje commented 8 years ago

It's the responsibility of the Command you register to implement CanExecute, i.e the one in your ViewModel. So using the demo project as an example:

        public ViewModelExampleBase()
          {
            this.AddTabCommand = new RelayCommand(AddTabCommandAction,CanAddTab);
         }
         private bool CanAddTab()
         {
            return false;
         }
Revsol commented 8 years ago

Yes and No, the CanAddTab function should not allow that the Button can be clicked. Try to Bind the Command to a normal Button and you can see what i mean, the Button will be grayed and can't be clicked. You use the MVVM Light Toolkit in your Demo, when you take a look at the Source of the Toolkit, you will see that the RelayCommand don't check if he can Execute, he just executes the Action.

public void Execute(object parameter)
{
    _execute();
}
sskodje commented 8 years ago

I'm afraid i don't fully understand what isn't working for you.

Is the problem that the button visually appears to be able to click, or that the button actually spawns new tabs when you click it.

Revsol commented 8 years ago

Sorry, my english is not the best ;) The standard behavior should be that the Button is not clickable when CanExecute is false. Because this is how all Buttons work in WPF. But the AddTabButton ignores the CanExecute. Its not good for User experience if he see a clickable Button that does nothing.

Revsol commented 8 years ago

I know, i annoy you with all this issues^^, but i really like the Tabcontrol and i want it to work with it. But unfortunately it has currently to many flaws to work with. I hope you understand that i just try to improve this already great control.

sskodje commented 8 years ago

It's no bother, i just misunderstood. i'll try add it for next update.

And remember, If you want to contribute, feel free to fork it and make a pull request :)

sskodje commented 8 years ago

This issue is fixed in version 1.2

Revsol commented 8 years ago

Great, thx