I have a textbox bound to an nullable integer in my model class. My CanExecute method works as expected. I want the button routed by the command to be disabled if the textbox value is 0. However, it will not disable when I completely cleare out the text box. How do I fix this validation issue?
xaml:
<TextBox Text="{Binding GameStats.TimeoutMinutes, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Button Command="{Binding CustomizeTimeoutTimeCmd}"/>
Model property:
private int? timeoutMinutes = 0;
public int? TimeoutMinutes {
get { return timeoutMinutes; }
set {
timeoutMinutes = value;
OnPropertyChanged("TimeoutMinutes");
}
}
Command CanExecute method:
public bool CanExecute(object parameter) {
if (scoreViewModel.GameStats.TimeoutMinutes == 0 || scoreViewModel.GameStats.TimeoutMinutes == null) {
return false;
} else {
return true;
}
}