我使用ObservableCollection
作爲我的一些綁定的ItemsSource,並且遇到了我想手動調用OnCollectionChanged
以通知綁定引擎需要重新檢查列表的場景。 (BindingList
類似物是OnListChanged
)。爲什麼在嘗試從ObservableCollection或BindingList的子類中獲取NullReferenceException?
這是麻煩開始的地方。令人難以置信的是,這些方法是protected
,不能在沒有繼承這些類型的情況下調用。 Ironpython supports this,但是當我試圖子類,它引人注目的失敗 - 甚至當我不指定任何重寫方法:
>>> class ObservableCollectionEx(System.Collections.ObjectModel.ObservableCollection):
... pass
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
SystemError: Object reference not set to an instance of an object.
>>> class BindingListEx(System.ComponentModel.BindingList):
... pass
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
SystemError: Object reference not set to an instance of an object.
我快要放棄的時候,和所有我想做的事是使一個受詛咒致電OnCollectionChanged
!幫幫我!
你能告訴我們任何一種類型的定義嗎? – JaredPar