开发者

ComboBox selected item text disappears when scrolling listbox

开发者 https://www.devze.com 2023-04-06 18:02 出处:网络
I have Combo boxes inside a list box and whenever the list box is scrolled and the combo box is scrolled off of the screen the list box is firing a selection change event on the combo box and setting

I have Combo boxes inside a list box and whenever the list box is scrolled and the combo box is scrolled off of the screen the list box is firing a selection change event on the combo box and setting the selected index of the combo box开发者_如何学编程 to null.

If I scroll back and forth multiple times you will see the selected item display and be removed by scrolling the list back and forth.

Does anyone have an idea on ow to fix this? I need the combo box to retain the selected index.

I have even changed the collection that holds the Combo-box data to a list from an observable collection and it still does the same thing.

I am using silver light v4, .net 4

Thanks...


This is probably a result of the default virtualising nature of the ListBox. As items scroll off the displayed the items are actually removed from the Visual Tree. If you don't have too many items in the list set the ItemsPanel property of the ListBox to an ItemsPanelTemplate containing a simple StackPanel.

Better would be to cease using the selection change event in this scenario, use a binding on the SelectedItem property instead.


I had the same issue, but with a datagrid. I tried this (preferable solution), but it didnt work for me.

Silverlight ComboBox and SelectedItem

So i had to go with this....

http://forums.silverlight.net/post/396922.aspx

0

精彩评论

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

关注公众号