Programmer Question
I'm trying to remove some objects from a ListBox that I have created, and for some reason ListBox.Items.IsReadOnly is true.
The following calls don't work:
myListBox.Items.Add("whatever")
myListBox.Items.Add("stuff")
myListBox.Items.Remove("whatever")
I get an exception:
{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)
I can set ListBox.ItemsSource, but working with .Items is much easier. I'm creating the ListBox like this:
let mutable myListBox= new ListBox()
Any ideas/suggestions would be greatly appreciated. Thanks.
Find the answer here
No comments:
Post a Comment