我创建了这个名为Cflowcontrol的自定义控件,我需要知道此控件的FlowDirection何时更改
所以这就是我所做的:
Inherits FlowLayoutPanel
Implements INotifyPropertyChanged
Private Fdirection As FlowDirection
Public Event FDirectionChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Private Sub NotifyPropertyChanged(ByVal info As String)
RaiseEvent FDirectionChanged(Me, New PropertyChangedEventArgs(info))
End Sub
Shadows Property FlowDirection As FlowDirection
Get
Return Fdirection
End Get
Set(value As FlowDirection)
If value <> Fdirection Then
Fdirection = value
NotifyPropertyChanged("FlowDirection")
End If
End Set
End Property
到目前为止它很好地告诉我什么时候属性改变它的价值 问题是面板内控件的流向不再改变
答案 0 :(得分:1)
您需要告诉基本控件自行更新:
Protected Sub OnNotifyPropertyChanged(info As String)
RaiseEvent FDirectionChanged(Me, New PropertyChangedEventArgs(info))
End Sub
Shadows Property FlowDirection As FlowDirection
Get
Return MyBase.FlowDirection
End Get
Set(value As FlowDirection)
If value <> MyBase.FlowDirection Then
MyBase.FlowDirection = value
OnNotifyPropertyChanged("FlowDirection")
End If
End Set
End Property