WPF DatePicker UpdateSourceTrigger PropertyChanged not working
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:
<Button Margin="10" Command="{Binding SubmitCommand}"
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.
Selected Date property does not work properly. I might be a bit late now, but you can use CurrentDateTimeText property of RadDatePicker
精彩评论