Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| using System; | |
| using System.Collections.Generic; | |
| using System.Text; | |
| using System.Globalization; | |
| using System.Windows.Controls; | |
| namespace DataBindingLab | |
| { | |
| //<Snippet2> | |
| class FutureDateRule : ValidationRule | |
| { | |
| public override ValidationResult Validate(object value, CultureInfo cultureInfo) | |
| { | |
| DateTime date; | |
| try | |
| { | |
| date = DateTime.Parse(value.ToString()); | |
| } | |
| catch (FormatException) | |
| { | |
| return new ValidationResult(false, "Value is not a valid date."); | |
| } | |
| if (DateTime.Now.Date > date) | |
| { | |
| return new ValidationResult(false, "Please enter a date in the future."); | |
| } | |
| else | |
| { | |
| return ValidationResult.ValidResult; | |
| } | |
| } | |
| } | |
| //</Snippet2> | |
| } | |