xamarin-forms-carouselview icon indicating copy to clipboard operation
xamarin-forms-carouselview copied to clipboard

Android: Suddenly the SelecteIndex Property binding didn't work.

Open soernt opened this issue 9 years ago • 1 comments

Hi, thank you very much for creating that control!

At the Android CarouselLayoutRenderer.updateSelectedIndex() function, you need to ensure that the carouselLayout.SelectedIndex Property should be set at the UI Thread. Otherwise all of a sudden the PropertyBinding didn't work anymore. I update it like this:

` private void updateSelectedIndex() { var center = _scrollView.ScrollX + (_scrollView.Width / 2); var carouselLayout = (CarouselLayout)Element; var calculatedIdx = (center / _scrollView.Width);

  using (var h = new Handler(Looper.MainLooper))
  {
    h.Post(() => carouselLayout.SelectedIndex = calculatedIdx);
  }
}

` Hope that helps someone.

soernt avatar Feb 01 '16 10:02 soernt

@soernt - thanks for that suggestion!

chrisriesgo avatar May 03 '16 14:05 chrisriesgo