I have 2 - XamDateTimeInput controls (Start & End dates), and I want to disable a Button control whenever either of these XamDateTimeInput controls have invalid input. Is there a way to do this in XAML?
Thank you. Is this property available in 14.1? I'm not seeing InvalidValueBehavior for the XamDateTimeInput control
Hello PMac, In order to set the behavior of the XamDateTimeInput whenever the value is invalid, you can use the InvalidValueBehavior property by setting it to RetainValue. This way the control will accept whatever value you enter without prompting you with an error message. If you require any further assistance on this matter, please do not hesitate to ask.
Great thanks! I was hoping there was a property to bind so I could avoid code-behind. But if not, then this will work.
Also, I notice that my ig:XamDateTimeInput control frequently barks about the input date being invalid when its manually typed:
Value '' could not be converted
But the date IS valid. Not sure how to turn this feature off. Is it possible to disable the UI visual warnings?
Hello PMac, By saying that you would like to disable a Button control whenever any of the XamDateTimeInputs have an invalid input, I presume you mean that the value of the input is not a valid DateTime instance. If this is the case, since the XamDateTimeInput does not introduce a property that indicates whether the value is a valid DateTime object or not, an approach I can suggest you is to manually perform the validation operation in code-behind by handling the ValueChanged event of both Inputs with a shared handler.XAML: <ig:XamDateTimeInput x:Name="inputA" ValueChanged="input_ValueChanged" /><ig:XamDateTimeInput x:Name="inputB" ValueChanged="input_ValueChanged" /> Code-behind: private void input_ValueChanged(object sender, EventArgs e){ if (IsValidDateTime(inputA.Text) && IsValidDateTime(inputB.Text)) button.IsEnabled = true; else button.IsEnabled = false;} private bool IsValidDateTime(string text){ DateTime temp; return DateTime.TryParse(text, out temp);} This way whenever the value of one of the controls has been changed, the ValueChanged event will fire and the Button will get enabled or disabled respectively based on whether both controls have a valid DateTime value or not. I have attached a sample application, where the approach from above has been used. If you require any further assistance on this matter, please do not hesitate to ask.