【发布时间】:2010-11-30 20:44:26
【问题描述】:
我正在尝试从我创建的 ListBox 中删除一些对象,但由于某种原因 ListBox.Items.IsReadOnly 为 true。
以下调用不起作用:
myListBox.Items.Add("whatever")
myListBox.Items.Add("stuff")
myListBox.Items.Remove("whatever")
我得到一个例外:
{System.InvalidOperationException: Operation not supported on read-only collection.
at System.Windows.Controls.ItemCollection.RemoveImpl(Object value)
at System.Windows.Controls.ItemCollection.RemoveInternal(Object value)
at System.Windows.PresentationFrameworkCollection`1.Remove(T value)
我可以设置 ListBox.ItemsSource,但使用 .Items 会容易得多。我正在创建这样的 ListBox:
let mutable myListBox= new ListBox()
任何想法/建议将不胜感激。谢谢。
【问题讨论】:
标签: silverlight f# listbox