I have a page with two buttons (I really have ten, but for example sake, lets say two), and they are both bound to a RelayCommand and each has a CommandParameter bound to two different columns from the database. Something like this,
<Button Command="{Binding DataContext.CopyPasteDataValueCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
CommandParameter="{Binding AccountID}">
<Button Command="{Binding DataContext.CopyPasteDataValueCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
CommandParameter="{Binding CustomerID}">
I have the associated RelayCommands setup properly in the code behind, and everything works just fine. Except when I select a different row in my DataGrid and I want to force rebinding and recalling of the RaiseCanExecute of both those buttons.
I would like to make something like this
private void RaiseAllCanExecuteChanged(){
CopyPasteDataValueCommand.RaiseCanExecuteChanged<string>("AccountID");
CopyPasteDataValueCommand.RaiseCanExecuteChanged<string>("CustomerID");
}
Of course this won't compile. But I'm wondering how would I do this, or if I indeed, CAN do this. Is this possible or do I really need to have multiple RelayCommands for each occurrence?
Thank you very much.