Как заставить промежутка времени определяется с включить/отключить кнопки WPF
I have a TimeSpan textbox, my objectif is to disable the button Save when the form of TIMESPAN is wrong (exp 90:00:00).. I try a code, it is correct for just once time..if I set 20:10:00 ..The Save button is enabled (correct). After that however the TIMESPAN is wrong 55:00:00, the button is enabled ( and the saving in database is 00:00:00)
How I can fix it to be work always correct? Thanks,
Что я уже пробовал:
код XAML:
<TextBox Name="txtTime" Margin="10,10,10,10" > <TextBox.Text > <Binding Path="Time" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True" Mode="TwoWay" > <Binding.ValidationRules> <local:DateTimeValidationRule ValidationStep="RawProposedValue"/> </Binding.ValidationRules> </Binding> </TextBox.Text> </TextBox>
The ViewModel :
public bool VarTIME ; [Required(ErrorMessage = "Time is required")] public TimeSpan Time { get { return time; } set { time = value; intervalString = Time.ToString(); TimeSpan reded; bool success = TimeSpan.TryParseExact(intervalString, "hh\\:mm\\:ss", CultureInfo.InvariantCulture, out reded); if (success) { VarTIME = true; } OnPropertyChanged("Time"); } } public SheduleTrainViewModel() { VarTIME = false; addTrain = new RelayCommand<string>(AddTrainFunction, canAddTrain); private bool canAddTrain(string obj) { return VarTIME; } }