WPF DatePicker UpdateSourceTrigger PropertyChanged not working...
Posted
by
user557352
on Stack Overflow
See other posts from Stack Overflow
or by user557352
Published on 2010-12-30T04:50:00Z
Indexed on
2010/12/30
4:53 UTC
Read the original article
Hit count: 1216
wpf
|updatesourcetrigger
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.
© Stack Overflow or respective owner