private void listpicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListPickerValidationControl control = (ListPickerValidationControl)sender; if (control.SelectedItem != null) { IValidationRule v = (IValidationRule)control.ValidationRule; control.IsValid = v.Validate(((CustomListBoxItem <Person>)control.SelectedItem).Value == "Choose ..." ? "" : "valid");; } }
public void ValidateObject(object sender, EventArgs e, UIElementCollection UIElements, List <ListPickerValidationControl> listpickers) { foreach (UIElement ui in UIElements) { if (ui.GetType() == typeof(ValidationControl)) { ValidationControl control = (ValidationControl)ui; IValidationRule v = (IValidationRule)control.ValidationRule; IsPageValid = v.Validate(control.Text); control.IsValid = IsPageValid; } else if (ui.GetType() == typeof(ListPickerValidationControl)) { ListPickerValidationControl control = (ListPickerValidationControl)ui; IValidationRule v = (IValidationRule)control.ValidationRule; IsPageValid = v.Validate(((ICustomListBox)control.SelectedItem).Value == "Choose ..." ? "" : "valid"); control.IsValid = IsPageValid; } } }