I rebuilt the Josh Smith CommandSink example from scratch and my version works without errors, except that my command buttons are inactive. I suppose this is because something is not installed correctly somewhere, so the commands will never be installed at CanExecute = trueor at some point will be installed at CanExecute = false.
But since data binding essentially takes place in XAML, I don’t know where to “set a breakpoint in the command” so that I can see at what time the button is assigned CanExecute = false or, for example. NOT assigned CanExecute = true.
Essentially, I have these command bindings in a view:
<UserControl.CommandBindings>
<sink:CommandSinkBinding Command="vm:CustomerViewModel.CloseCommand"/>
<sink:CommandSinkBinding Command="vm:CustomerViewModel.ShowInformationCommand"/>
</UserControl.CommandBindings>
and in my CustomerViewModel the command is defined as follows:
public static readonly RoutedCommand CloseCommand = new RoutedCommand();
public bool CanBeClosed
{
get { return _customer.IsOpen; }
}
public void Close()
{
_customer.IsOpen = false;
this.OnPropertyChanged("CanBeClosed");
this.OnPropertyChanged("CanBeApproved");
}
MVVM , M-VM-M, " ".
, - " ", ASP.NET, , CanExecute = true CanExecute = false.
WPF/MVVM, , , , , ?
:
, , , , , , .
, , Josh Smith , CommandSinkBinding.OnCommandSinkChanged:
if (!ConfigureDelayedProcessing(depObj, commandSink))
ProcessCommandSinkChanged(depObj, commandSink);