本文整理匯總了VB.NET中System.Windows.FrameworkElement.BindingGroup屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET FrameworkElement.BindingGroup屬性的具體用法?VB.NET FrameworkElement.BindingGroup怎麽用?VB.NET FrameworkElement.BindingGroup使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。
在下文中一共展示了FrameworkElement.BindingGroup屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Type1
Public Class Type1
Public Property PropertyA() As String
Public Sub New()
PropertyA = "Default Value"
End Sub
End Class
Public Class Type2
Public Property PropertyB() As String
Public Sub New()
End Sub
End Class
Public Class BindingGroupValidationRule
Inherits ValidationRule
Public Overrides Function Validate(ByVal value As Object, ByVal cultureInfo As System.Globalization.CultureInfo) As ValidationResult
Dim bg As BindingGroup = TryCast(value, BindingGroup)
Dim object1 As Type1 = Nothing
Dim object2 As Type2 = Nothing
For Each item As Object In bg.Items
If TypeOf item Is Type1 Then
object1 = TryCast(item, Type1)
End If
If TypeOf item Is Type2 Then
object2 = TryCast(item, Type2)
End If
Next item
If object1 Is Nothing OrElse object2 Is Nothing Then
Return New ValidationResult(False, "BindingGroup did not find source object.")
End If
Dim string1 As String = TryCast(bg.GetValue(object1, "PropertyA"), String)
Dim string2 As String = TryCast(bg.GetValue(object2, "PropertyB"), String)
If string1 <> string2 Then
Return New ValidationResult(False, "The two strings must be identical.")
End If
Return ValidationResult.ValidResult
End Function
End Class
示例2:
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
sp1.BindingGroup.UpdateSources()
End Sub