In WP7.1 ListBox, the selected index does not work properly. How can a selected item appear on top?

SCENARIO:

  • On Windows Phone 7, I use a list.
  • Suppose there are 200 elements.
  • Now I select the 150th item in the list
  • I want the list to load and select (and show) the 150th item at the top of the list after loading.

PROBLEM:

  • I am using HookScrollViewer () as indicated on this page ( List offset in WP7 )
  • When you first load an item in the list, the desired item is not displayed (say, it shows the 148th item).
  • I exit this page and click on the 150th element again.
  • Now the list index is correct, and it shows the 150th element exactly at the top.

Question:

  • Am I using the right solution?
  • What is wrong, what I do, I tried to determine a solution, but could not!

Hint:

  • If you have a Windows phone, download the application: http://tinyurl.com/9298cdx
  • Open any chapter and write down something (by pressing Long press) in the middle of the chapter.
  • Close the application and open the application again.
  • Click on a bookmark to open it.
  • The first time he will not go to the exact location.
  • Now DO NOT close the application, just click the "Back" button and click the bookmark again.
  • This time the correct location!
  • The question is, what happened the first time?

READ PAGE CODE:

Many thanks!

+8
c # windows-phone-7 xaml
source share
2 answers

After the battle, I found an urgent problem and its solution.

Actual problem:

  • I use external fonts except those that are included by default in WP.
  • External fonts take some time to load into memory, and then the text is displayed.
  • At the same time, the list is loading already, and the font is loading.
  • Finally, the text is displayed and (maybe due to the extension), the selected index location moves down.
  • Without closing the application, the font seems to remain in memory, and the next time it does not take much time, and the identifier of the pointer is displayed correctly.

My decision:

  • I loaded (external) fonts while loading the main page. This takes a small amount of time and therefore does not affect application performance (in terms of download time).

I wish if any architect can better explain what happened, or, in other words, I’m interested in knowing the technical background of the “current problem”.

Thanks to all those who made suggestions.

+1
source share

I think your data is not updated. You can try using INotifyPropertyChanged, look at an example that you will understand how to use

0
source share

All Articles