本文整理汇总了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