尽管有ByRef,但可观察的收藏品并不算什么

时间:2018-05-16 10:32:05

标签: wpf vb.net observable ref

我在我的模型Public Sub LoadAnnos(ByRef annotationList As ObservableCollection(Of PdfMarkupAnnotationDataWrapper), pdfViewer As PdfViewerControl) annotationList = XMLSerialization.Deserialize() For Each anno In annotationList AddAnnotationsToPdf(pdfViewer, anno) Next End Sub 中从我的viewmodel调用一个方法,它有一个ObservableCollection作为参数(ByRef),如下所示:

AddAnnotationsToPdf(pdfViewer, anno)

在这个方法中,我为集合赋值:

LoadAnnos

现在这个集合有一些价值,并不是什么都没有。

AnnotationList在我的ViewModel中触发一个事件(我称之为方法 Public Sub PdfViewerTextMarkupAnnotationCreating(ByVal sender As Object, ByVal e As PdfTextMarkupAnnotationCreatingEventArgs) _pdfModel.AddAnnotationsToList(AnnotationList, e) If AnnotationList IsNot Nothing Then 'AnnotationList is nothing even tough it wasn't in LoadAnnos XMLSerialization.Serialize(AnnotationList) End If )。 如果我现在在这个事件中使用集合NUnit,那就没什么了。

以下是活动:

NUnit

End Sub

0 个答案:

没有答案