123456789101112131415161718192021222324252627282930 |
- namespace GDNXFD.Alert.Config.Validations
- {
- using GDNXFD.Alert.Config.ViewModel;
- using System;
- using System.Windows.Controls;
- using System.Windows.Data;
- /// <summary>
- /// Rule for required fields
- /// </summary>
- public class SelectedAlertCategoryValidationRule : ValidationRule
- {
- /// <summary>
- /// When overridden in a derived class, performs validation checks on a value.
- /// </summary>
- /// <param name="value">The value from the binding target to check.</param>
- /// <param name="cultureInfo">The culture to use in this rule.</param>
- /// <returns>
- /// A <see cref="T:System.Windows.Controls.ValidationResult"/> object.
- /// </returns>
- public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
- {
- if (((RuleFormViewModel)((((BindingExpression)(value)).DataItem))).SelectedAlertCategory == null)
- return new ValidationResult(false, "必须选择一个有效值!");
- return new ValidationResult(true, null);
- }
- }
- }
|