WPF DatePicker UpdateSourceTrigger PropertyChanged not working...
- by user557352
I am using MVVM and want to enable a button on text change of datepicker control..
XAML Code
Binding on DatePicker
SelectedDate="{Binding InactiveDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayDate="{Binding InactiveDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Binding on Button
View Model Code
I am using a DelegateCommand for button click
View Model Delegate Initialization
SubmitCommand = new DelegateCommand(OnSubmitRequested, AllowSubmit, Controller);
The AllowSubmit implementation
private bool AllowSubmit()
{
return InactiveDate != null;
}
InactiveDate Property implementation
public DateTime? InactiveDate
{
get
{
return _inactiveDate;
}
set
{
_inactiveDate = value;
SubmitCommand.RaiseCanExecuteChanged();
PropertyChanged(this, new PropertyChangedEventArgs("InactiveDate"));
}
}
SubmitCommand.RaiseCanExecuteChanged() should enable the button once I enter any character on DateTimePicker but it is not happening.