MilMike
MilMike

Reputation: 12831

WPF Listbox Selection problem

I have a strange problem with a listbox. I added only the listbox and a button which adds items to the listbox. If I click an item in the listbox it seems to have some strange multi selection mode on or something... i recorded a short screen cast, see for your self:

http://www.youtube.com/watch?v=zV4424ipNEA
any ideas whats wrong?

Upvotes: 1

Views: 971

Answers (1)

brunnerh
brunnerh

Reputation: 184296

That is a known issue, as all those strings are the same the selection gets confused because they all are essentially the same object. If you create two identical strings in .NET it does not necessarily create a new one but may reuse the first instance, i am not an expert on this though.

Either wrap the strings in a class (make them the Content of a ListBoxItem for example) or make sure the values are unique.

Upvotes: 4

Related Questions