我已經定義了控制:F#的Silverlight 3.0自定義控件屬性拋出:NullReferenceException異常
static member ItemsProperty : DependencyProperty =
DependencyProperty.Register(
"Items",
typeof<MyMenuItemCollection>,
typeof<MyMenu>,
null);
member this.Items
with get() : MyMenuItemCollection = this.GetValue(MyMenu.ItemsProperty) :?> MyMenuItemCollection
and set (value: MyMenuItemCollection) = this.SetValue(MyMenu.ItemsProperty, value);
的問題發生在訪問:
for menuItem in this.Items do
let contentElement: FrameworkElement = menuItem.Content
在那裏我得到空引用異常在這個.Items;
'商品' 扔類型的異常 'System.NullReferenceException'
後不久我在構造函數初始化:
do
this.Items <- new CoolMenuItemCollection()
嗨,這不是一個討論的論壇之多的問題和答案的地方。假設任何人查看你的帖子沒有閱讀你的「以前的帖子」 – 2010-05-18 18:28:43
夠真實 - 犯了大聲打字。以前的帖子是完全無關緊要的。 – akaphenom 2010-05-18 18:31:54