Archive for May, 2010

Scrolling listboxes in Silverlight

Tuesday, May 18th, 2010

We have been doing quite a bit of work with Silverlight recently. I was working on a list of questions for a Silverlight-based test. The list of questions was placed into a Silverlight ListBox control. I needed to automatically scroll to the selected question within the ListBox. This seemed like a very easy thing to do because the Silverlight ListBox control have a ScrollIntoView() method. I called the method and nothing happened – very frustrating.

I searched the web to look for an answer – I found many people were experiencing the same problem. Here was the source of my problem – I had included the ListBox control inside a ScrollViewer control – I put the ListBox inside the ScrollViewer control because I thought the ListBox itself could not scroll. Once I removed the ScrollViewer control surrounding the ListBox, the call to the ScrollIntoView() worked just fine.