CanExecute never called on WPF

Topics: Prism v4 - WPF 4
Mar 3, 2011 at 12:14 PM

I've been using Prism for more than a year now on Silverlight and have never seen this.  I have a CanExecute method that just doesn't fire.  However, the Execute method DOES.  So I know the command is bound correctly.

This is my code:

_GetNextClaimCommand = new DelegateCommand(ExecuteGetNextClaimCanGetNextClaim);

private bool CanGetNextClaim() { return false; }

CanGetNextClaim is NEVER called for some ungodly reason, yet the ExecuteGetNextClaim does!

Please help!!  P.S. I'm using Prism 4, latest official release.
Mar 3, 2011 at 1:41 PM


Take into account that you need to call the _GetNextClaimCommand´s RaiseCanExecuteChanged method in order for the CanNextGetClaim to be called.

You might find the Commanding QuickStart handy, where you see an example of how you can implement this.

I hope you find this information useful.


Miguel Bronzovic


Mar 3, 2011 at 2:29 PM

OK looks like I was actually binding to a nearly identical command on another viewmodel, which is why the Execute seemed to be executing.  My bad.

Miguel, I am aware of the need to call RaiseCanExecuteChanged(); however that isn't necessary for the initial call to CanGetNextClaim().  Thanks for your response!