我的ICollectionView
就像这样Observable
:
Public cvAnnotations As CollectionViewSource = New CollectionViewSource()
Private Property _annotationList As ObservableCollection(Of PdfMarkupAnnotationDataWrapper)
Public Property AnnotationList As ObservableCollection(Of PdfMarkupAnnotationDataWrapper)
Get
Return _annotationList
End Get
Set(value As ObservableCollection(Of PdfMarkupAnnotationDataWrapper))
_annotationList = value
cvAnnotations.Source = _annotationList
FilteredList = cvAnnotations.View
OnPropertyChanged()
End Set
End Property
Private Property _filteredList As ICollectionView
Public Property FilteredList As ICollectionView
Get
cvAnnotations.View.Filter = Function(x As PdfMarkupAnnotationDataWrapper) FilterAnnotations(x)
_filteredList = cvAnnotations.View
Return _filteredList
End Get
Set(value As ICollectionView)
_filteredList = value
OnPropertyChanged()
End Set
End Property
现在textbox
中的XAML
绑定到属性Filter
,当用户输入内容时,该属性应更新ICollectionView
的过滤器:
Private Property _filter As String
Public Property Filter As String
Get
Return _filter
End Get
Set(value As String)
'Here it is null after a new item was added to the Observable
FilteredList.Refresh()
_filter = value
OnPropertyChanged()
End Set
End Property
这项工作正常,直到我将一个项目添加到ICollectionView
的来源(observableCollection AnnotationList
)
因此,在添加新项目然后在过滤器文本框中输入内容后,ICollectionView
为null