I can't find, how to change the item position in the XAMCarouselListBox. I'd like to show the select item always in the middle of the path. The path is a simple horizontal line.
I've solved this problem: I react on selection change and move there the items right or left:
....
xamCarouselListBox1.SelectionChanged += new SelectionChangedEventHandler(xamCarouselListBox1_SelectionChanged);
void xamCarouselListBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) {
int centerPos = xamCarouselListBox1.ViewSettings.ItemsPerPage / 2;
int centerIndex=-1;
for (int i=0; i<xamCarouselListBox1.Items.Count; i++) {
CarouselListBoxItem clbi = (CarouselListBoxItem)xamCarouselListBox1.RecyclingItemContainerGenerator.ContainerFromIndex(i);
if (clbi != null && i==centerPos + xamCarouselListBox1.ScrollInfo.VerticalOffset) {
centerIndex = i;
break;
}
int selectedOffset = xamCarouselListBox1.SelectedIndex - centerIndex;
if (selectedOffset > 0) {
for (int i=0; i<selectedOffset; i++) {
xamCarouselListBox1.ScrollInfo.LineRight();
} else {
for (int i=0; i<-selectedOffset; i++) {
xamCarouselListBox1.ScrollInfo.LineLeft();
This above code only sort of workd for me. It will center some items, but not others.
I am utilizing a CarouselListBox and I am clicking on my items to 'select' them.
Can anyone confirm or fix the above code? I copied and pasted it out of the form, so I can't see how it is a typo or mistake on my part. It could be possible that one of my CarouselListBox settings are messing up the selection code.