Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
XamDateTimeEditor date validation
posted

Hi ,

I have done validation for XamDateTimeEditor . The code in value changed event :

 

 

 

 

 

 

 

DateTime dtnow = DateTime

.Now;

 

 

if

(dt1 > dtnow)

{

 

 

MessageBox.Show("Please Enter Valid Firm Founded Date:", "validation", MessageBoxButton.OK, MessageBoxImage

.Error);

xamDateTimeEditorFounded.Text =

string.Empty;

e.Handled =

false;

 

 

return;

 

It's working but two lines are displayed in the control, when focus is removed from there they will disppear. Please tell me correct way to validate the control's date if it's greater than today's date

  • 54937
    Offline posted

    The ValueChanged event could while the user is changing the value (e.g. while typing) so I wouldn't think using that event is the best option. Since you are just trying to make sure it's not a date in the future perhaps you could just set the ValueConstraint.MaxInclusive to DateTime.Today.