I make two methodes like this:
private void Next(string argument) { Current = Clients[Clients.IndexOf(Current) + 1]; ((DelegateCommand)NextCommand).RaiseCanExecuteChanged(); }
private void Previous(string argument) { Current = Clients[Clients.IndexOf(Current) - 1]; ((DelegateCommand)PreviousCommand).RaiseCanExecuteChanged();
}
and bind to the xaml:
Every thing work fine. And the next button becomes inactive/grey out when it hits the last post. The problem is it (the Next button) still inactive when I click the Previous button. The Next button becomes inactive all the time. My question is how I could make 开发者_开发技巧the Next button active again? Thank for all help.
I assume you are talking about a WPF Application.
There are several reasons your button could become / stay inactive:
- Your CanExecute implementation is faulty and returns false even if it should return true
- You didnt implement CanExecute or didnt hook it up correctly
- The CommandManager didn't realize it's time to requery the commands
- You've got a problem with the Focus on your Window / Control
You need to show more of the code so it gives us a broader picture of what you are trying to do.
精彩评论