Silverlight에서 INotifyPropertyChanged를 사전에 바인딩 할 때와 같이 작동시키지 못합니다. 아래 예제에서는 페이지가 사전에 바인딩되지만 괜찮 았지만 텍스트 상자 중 하나의 내용을 변경하면 CustomProperties 속성 설정자가 호출되지 않습니다. CustomProperties 속성 setter는 CustomProperties가 설정된 경우에만 호출되며 내부의 값이 설정되지 않은 경우에는 호출됩니다. 사전 값에 대한 일부 유효성 검사를 시도하고 있으므로 사전 내의 각 값이 변경 될 때 일부 코드를 실행하려고합니다. 내가 여기서 할 수있는 일이 있니?Silverlight에서 INotifyPropertyChanged를 사용하여 사전에 바인딩
C 번호
Partial Public Class MainPage
Inherits UserControl
Public Sub New()
InitializeComponent()
Dim ent As New MyEntity
ent.CustomProperties.Add("Title", "Mr")
ent.CustomProperties.Add("FirstName", "John")
ent.CustomProperties.Add("Name", "Smith")
Me.DataContext = ent
End Sub
End Class
Public Class MyEntity
Implements INotifyPropertyChanged
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Private _customProps As Dictionary(Of String, Object)
Public Property CustomProperties As Dictionary(Of String, Object)
Get
If _customProps Is Nothing Then
_customProps = New Dictionary(Of String, Object)
End If
Return _customProps
End Get
Set(ByVal value As Dictionary(Of String, Object))
_customProps = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("CustomProperties"))
End Set
End Property
End Class
XAML이
<TextBox Height="23" Name="TextBox1" Text="{Binding Path=CustomProperties[Title], Mode=TwoWay}" />
<TextBox Height="23" Name="TextBox2" Text="{Binding Path=CustomProperties[FirstName], Mode=TwoWay}" />
<TextBox Height="23" Name="TextBox3" Text="{Binding Path=CustomProperties[Name], Mode=TwoWay}" />
감사합니다. 나는 wpf의 ObservableDictionary 구현을 tweeked tweeked : http://drwpf.com/blog/2007/09/16/can-i-bind-my-itemscontrol-to-a-dictionary/ –