Binding issue in Custom Image Control
I am facing a really strange issue in WP7. I have created a custom image control (due to many many reasons), when i use that custom image control in ListBox, it's shows proper images for the first 21 images. After that, the image control start repeating the old images for the remaining items. For example, i have 50 items in Listbox, the first 21 items in listbox will have proper images but the remaining 29 items have old images (i.e. of 21 items). Another strange thing is that, when i Scroll the page from top to bottom and then from bottom to top, the first 21 images places are changed now (meaning they are placed wrongly!)
When i tried to debug the code, i found that there are only 21 instances have been created of my custom control and listbox is reusing those 21 objects for the remaining item.
guys, i am new to this WP7 and i tried to find relative learning material but couldn't find any clue to this problem. Can anyone please tell me what's going on? and how should i avoid this beh开发者_如何学Pythonavior?
FYI: I have extended my control with UserControl class and also tried it with ContentControl class.
I've seen this behaviour a lot.
The general recommendation is to not use custom controls inside a listbox. I knwo peopel who've been told this by MSFT as "the solution".
If you really can't, then look at removing the virtualization from the listbox as that is likely the real problem.
精彩评论