Fixing a side effect w/ the Expander Control in Windows Phone

I am a huge fan of the Telerik Windows Phone UI controls, I think they are simple to use and they ‘JUST WORK’.

When building a large list of items performance can become an issue. Because of this the RadJumpList will attempt to recycle objects as you are scrolling rather than create new ones. This is great as it reduces the memory footprint and generally means better performance.

However, this recycling is not without some side effects. Once such side effect pops up when you are using the ExpanderControl to allow your users to expand and collapse data.

Here is the side effect.
Lets say you have a list of 1000 items. If you expand the 1st item in the list and then start scrolling at some point you will see another item which is expanded. This is annoying because your users did not expand that item, well directly that is. This item will be expanded because the underlying object was recycled from the original item you expanded.

Solving this side effect is trivial and easy.
The easiest way to solve this is to setup your ExpanderControl as below
Expander

Notice that ExpanderControl has a binding setup for IsExpanded, this is key. This binding should be bound to a property on your VM, making sure the VM property raises property changed.

Once you have this setup your issues should be solved.

Hope this helps.

Till next time,

This entry was posted in C#, Windows Phone and tagged . Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply