开发者

WPF Listbox Selection problem

开发者 https://www.devze.com 2023-04-01 23:45 出处:网络
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

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 s开发者_运维技巧elf:

http://www.youtube.com/watch?v=zV4424ipNEA

any ideas whats wrong?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号