后面的代码。
Class MainWindow
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
Dim myBinding As New Binding
With myBinding
.Source = Image1.Source
.Mode = BindingMode.Default
.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
End With
End Sub
End Class
那么,为什么 myBinding 在后面的代码中不起作用?
答案 0 :(得分:0)
为了在其源属性发生更改时更新绑定,您需要指定一个路径:
Dim myBinding As New Binding
With myBinding
.Source = Image1
.Path = new PropertyPath("Source")
End With
除此之外,设置BindingMode.Default
和UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
是没有意义的。对此绑定没有影响。