Do anyone know why being specific with the MVVM Light RelayCommand generic type would cause its canExecute to always resolve to false for the binding? In order to get the correct behavior I had to use an object and then convert it to the desired type.
NOTE: canExecute was simplified to a boolean for testing the block that does not work and is normally a property CanRequestEdit.
Does NOT work:
public ICommand RequestEditCommand {
get {
return new RelayCommand<bool>(commandParameter => { RaiseEventEditRequested(this, commandParameter); },
commandParameter => { return true; });
}
}
Works:
public ICommand RequestEditCommand {
get {
return new RelayCommand<object>(commandParameter => { RaiseEventEditRequested(this, Convert.ToBoolean(commandParameter)); },
commandParameter => { return CanRequestEdit; });
}
}
XAML:
<MenuItem Header="_Edit..." Command="{Binding RequestEditCommand}" CommandParameter="true"/>