我在Visual Studio 2010 Express中使用VB.NET和WPF。
目前,我有:
我的问题是,每当StateType发生更改时,DataGrid中的image列都不会更改。我一直在尝试使用 IPropertyChangedNofity ,但没有任何变化,所以要么我使用不正确,要么我需要使用其他方法。
Implements INotifyPropertyChanged
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
AddHandler ControllerRef.StateChanged, AddressOf StateChangeHandler
Private Sub StateChangeHandler(NewState As State)
MsgBox(NewState)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("CurrentState"))
End Sub
提前致谢
答案 0 :(得分:1)
确保PropertyChanged事件通知UI您绑定的属性名称,而不是触发更改的属性。例如:
Imports System.ComponentModel
公共类DownloadListItem:实现INotifyPropertyChanged
Friend Enum StateEnum
State1 = 0
State2 = 1
End Enum
Private _CurrentState As StateEnum
Private Sub ChangeEnumValue(NewValue As StateEnum)
_CurrentState = NewValue
OnPropertyChanged("ImageURI")
End Sub
Public ReadOnly Property ImageURI As String
Get
' TODO: Implement conditional logic to return proper value based on CurrentState Enum
End Get
End Property
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
Protected Sub OnPropertyChanged(PropertyName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(PropertyName))
End Sub
结束班