0

让我们承认一段代码:

    [...]
    Private _filterContacts As FilterContacts
    Public Property FilterContacts() As FilterContacts
        Get
            Return _filterContacts
        End Get
        Set(ByVal value As FilterContacts)
            _filterContacts = value
            OnPropertyChanged("FilterContacts")                    
        End Set
    End Property

    Private _branchType As Nullable(Of Integer)
    Public Property BranchType As Nullable(Of Integer)
        Get
            Return _branchType
        End Get

        Set(ByVal value As Nullable(Of Integer))
            _branchType = value
            OnPropertyChanged("BranchType")                
        End Set
    End Property
    [...]

    Public Sub SomeSub()
        FilterContacts.BranchType = BranchType
    End Sub

我实际上更改了过滤器的“branchType”,但我希望收到通知,FilterContacts 已更改,而不仅仅是其中一个字段。可能吗?谢谢!

4

1 回答 1

2
Set(ByVal value As Nullable(Of Integer))
    _branchType = value
    OnPropertyChanged("BranchType")                
    OnPropertyChanged("FilterContacts")      
End Set

或者,如果您想使对象上的所有属性无效,只需执行以下操作:

OnPropertyChanged("")      
于 2012-05-09T12:55:25.273 回答