Page 1 of 1

Removing ListBox item.

Posted: 23 Sep 2013, 18:08
by Justei
Hey there! Fast question I figured more people would run into sooner or later anyway.

I have a listbox that I populate with code.
And then when I want to remove one of the items, I'm unsure on how to go about that!

Here's the code I'm using right now, and it doesn't seem to remove the item. In fact it does absolutely nothing (in terms of removing, everything else is just fine).

ListBoxItem itemToDelete = _characterList.GetSelectedItem().As<ListBoxItem>();

        // Do some magic stuff here, unimportant. But it Does use the button and actually verifies that the button reference is correct.

       // Nothing happens when I call Dispose. Wrong function?
        _characterList.GetSelectedItem().Dispose();



Re: Removing ListBox item.

Posted: 23 Sep 2013, 19:18
by sfernandez
_characterList.GetItems().Remove(_characterList.GetSelectedItem());
Is that what you are looking for?