I've got a button with a simple command binding on my view:
<Window ...>
<Window.DataContext>
<vm:ShellViewModel />
</Window.DataContext>
...
<Button Command="{Binding DoSomethingCoolCommand}" Content="Execute" />
And the vm:
public class ShellViewModel : ObservableObject {
private RelayCommand _doSomethingCoolCommand;
public ICommand DoSomethingCoolCommand {
get {
return _doSomethingCoolCommand ??
(_doSomethingCoolCommand = new RelayCommand(DoSomethingCool));
}
}
private void DoSomethingCool() { ... }
However, the button is disabled at application/view startup, and I can't get it enabled. I've tried passing a command execution evaluation to the RelayCommand
and also set IsEnabled
on the view. Am I missing something?
Edit
RelayCommand and ObservableObject are from the mvvm foundation project, as stated in the tags. Link: https://mvvmfoundation.codeplex.com