0
我有一個包含帳戶不同功能區域的窗口。細節,角色,類型,合同等。窗口的DataContext被設置爲'AccountViewModel'。在AccountViewModel內部,屬性之一是包含詳細信息的「帳戶」。我需要用戶能夠更新這些細節。如何通知屬性在更改時調用Update()代碼?綁定到類別屬性時的屬性通知
這裏是我有什麼
<TextBox x:Name="txtAccountNumber" Grid.Row="0" Grid.Column="1" Text="{Binding Path=Account.AccountNumber, UpdateSourceTrigger=LostFocus}" />
Sub New()
InitializeComponent()
DataContext = AccountViewModel
End Sub
Class AccountViewModel
Public Property Account As Account
Get
Return _account
End Get
Set(ByVal value As Account)
_account = value
End Set
End Property
End Class
Public Class Account
Private _accountNumber As String
<DisplayName("Account Number")> _
Public Property AccountNumber As String
Get
Return _accountNumber
End Get
Set(ByVal value As String)
_accountNumber = value
End Set
End Property
End Class
這表明我正確的方向,謝謝!對於其他人來說,我在AccountViewModel類的Sub New()中設置_account時添加了以下行:AddHandler _account.PropertyChanged,AddressOf OnAccountPropertyChanged – knockando 2011-06-13 21:11:22