views:

909

answers:

2

Is it possible to always keep selected item in the middle of a listbox? If the user selects an item, I want to scroll so that the newly selected item is in the middle.

I guess it want be possible for the 'edge cases' (the first and last few items), but that's ok.

A: 

It is possible with couple of lines of custom code. Here's a discussion of a sample implementation. You might need to tweak it a bit to account for even number of items, insted of only odd number, but the general idea is the same.

Franci Penov
The CarouselListBox seems to include a lot of properties that I cant find on a regular ListBox. How can i get the ScrollViewer for my listbox?
Vegar
+1  A: 

David Anson posted some articles on his blog that might help you here: Part 1 and Part 2. He gives an extension method that centers an item in an List Box. You might be able to build on that.

Samuel Jack