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.
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.
来源:https://stackoverflow.com/questions/592911/wpf-listbox-centering-selected-item