27Mar/124

Fixing the LongListSelector part 1: Recompile the source.

Today I came across an issue with the LongListSelector, part of the Silverlight for Windows Phone Toolkit. Solving the issue seemed pretty simple in the end, but first some background.

The LongListSelector is a control that can be used to create a list of groups. A good example of this is the contacts list in the people hub. In that list the contacts are organized based on the first letter of their name. Every group contains a header, in this case the first letter, and using this header you can very easily switch between groups. By using the LongListSelector from the toolkit, developers can create the same experiences in their apps.

The issue I encountered was the fact that I was getting ArgumentOutOfRange exceptions when an item was added to a group dynamically. This issue was supposed to be fixed in the November 2011 release, as stated in the release notes:

LongListSelector bug fixes around OutOfRange exceptions, wrong ordering of items, grouping issues, and scrolling events. ItemTuple is now refactored to be the public type LongListSelectorItem to provide users better access to the values in selection changed handlers.

Well this doesn't seem to be the case exactly. Most of those fixes were actually in changeset 71191 and 71199, which according to the codeplex site are included in the November release. This appears to be not so. When comparing some of the code in the installed Microsoft.Phone.Controls.Toolkit.dll to the source on codeplex it seems to be the case that the installed dll is compiled from a revision at least before 70993.

The solution is simple:

- Download the latest source from codeplex (this currently also includes some fixes to the PhoneTextBox, changeset 74775).

- Compile it.

- Use the resulting dll instead of the one installed by the toolkit.

Happy coding!

Did you like this? Share it:
Comments (4) Trackbacks (0)
  1. Hi i have tried to recompile the 74775 source and latest one to and i cant get it to work with the WP 7.1 SDK. Can you please share a sample for download?

  2. Thank you Johan, your post has unblocked me. I was getting ArgumentOutOfRange (Parameter name: index) exception when dynamically adding an item/group using the “November” release (which installs into Oct11 folder). Using the resulting binary from compiling the latest source has made the issue go away.

  3. Thanks for this info, saved my day! After populating the longlist at runtime, and removing one item from one group and adding it to another, the groups would be messed up. I realized I was using an old version of the toolkit and downloaded the latest release – still did not work. Your site made me download the source, compile, and voilá! 🙂


Leave a comment

No trackbacks yet.