本文整理汇总了C#中System.Windows.Controls.ValidationRule.ValidationStep属性的典型用法代码示例。如果您正苦于以下问题:C# ValidationRule.ValidationStep属性的具体用法?C# ValidationRule.ValidationStep怎么用?C# ValidationRule.ValidationStep使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Controls.ValidationRule
的用法示例。
在下文中一共展示了ValidationRule.ValidationStep属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
public class ValidateDateAndPrice : ValidationRule
{
// Ensure that an item over $100 is available for at least 7 days.
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
BindingGroup bg = value as BindingGroup;
// Get the source object.
PurchaseItem item = bg.Items[0] as PurchaseItem;
object doubleValue;
object dateTimeValue;
// Get the proposed values for Price and OfferExpires.
bool priceResult = bg.TryGetValue(item, "Price", out doubleValue);
bool dateResult = bg.TryGetValue(item, "OfferExpires", out dateTimeValue);
if (!priceResult || !dateResult)
{
return new ValidationResult(false, "Properties not found");
}
double price = (double)doubleValue;
DateTime offerExpires = (DateTime)dateTimeValue;
// Check that an item over $100 is available for at least 7 days.
if (price > 100)
{
if (offerExpires < DateTime.Today + new TimeSpan(7, 0, 0, 0))
{
return new ValidationResult(false, "Items over $100 must be available for at least 7 days.");
}
}
return ValidationResult.ValidResult;
}
}