I cannot seem to get validation to work correctly on a template datepicker column, any suggestions?
This is the property I am binding to:
[System.Runtime.Serialization.DataMemberAttribute(Name="End Date")]public System.DateTime EndDate {get {return this.EndDateField;}set {if ((this.EndDateField.Equals(value) != true)) {
if (value < StartDate)throw new System.Exception("The end date must occur after the start date");
if(value.Month != StartDate.Month || value.Year != StartDate.Year)throw new System.Exception("Occurrences may not span multiple months or years");
this.EndDateField = value;this.RaisePropertyChanged("EndDate");}}}
and this is the xaml for the column:
<igGrid:TemplateColumn HeaderText="End Date" Key="EndDate"><igGrid:TemplateColumn.ItemTemplate><DataTemplate><TextBlock Text="{Binding EndDate}"/> </DataTemplate></igGrid:TemplateColumn.ItemTemplate><igGrid:TemplateColumn.EditorTemplate><DataTemplate><basics:DatePicker SelectedDate="{Binding EndDate, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=Explicit}" /> </DataTemplate></igGrid:TemplateColumn.EditorTemplate></igGrid:TemplateColumn>
Hi Danny,
Your TemplateColumn and property are set up correctly. The DatePicker just doesn't have the Validation states setup in its template.
Here is a link to an article on how to customize the DatePicker to have those states:
http://www.rameshsubramanian.org/2009/09/silverlight-datepicker-validation.html
-SteveZ
Once again, you da man Stephen, Thank You.