本文整理汇总了VB.NET中System.Windows.Controls.ValidationRule.ValidationStep属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ValidationRule.ValidationStep属性的具体用法?VB.NET ValidationRule.ValidationStep怎么用?VB.NET ValidationRule.ValidationStep使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了ValidationRule.ValidationStep属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Validate
Public Class ValidateDateAndPrice
Inherits ValidationRule
' Ensure that an item over $100 is available for at least 7 days.
Public Overrides Function Validate(ByVal value As Object, ByVal cultureInfo As CultureInfo) As ValidationResult
Dim bg As BindingGroup = TryCast(value, BindingGroup)
' Get the source object.
Dim item As PurchaseItem = TryCast(bg.Items(0), PurchaseItem)
Dim doubleValue As Object = Nothing
Dim dateTimeValue As Object = Nothing
' Get the proposed values for Price and OfferExpires.
Dim priceResult As Boolean = bg.TryGetValue(item, "Price", doubleValue)
Dim dateResult As Boolean = bg.TryGetValue(item, "OfferExpires", dateTimeValue)
If (Not priceResult) OrElse (Not dateResult) Then
Return New ValidationResult(False, "Properties not found")
End If
Dim price As Double = CDbl(doubleValue)
Dim offerExpires As Date = CDate(dateTimeValue)
' Check that an item over $100 is available for at least 7 days.
If price > 100 Then
If offerExpires < Date.Today + New TimeSpan(7, 0, 0, 0) Then
Return New ValidationResult(False, "Items over $100 must be available for at least 7 days.")
End If
End If
Return ValidationResult.ValidResult
End Function
End Class