Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
soernt opened this issue Feb 1, 2016 · 1 comment
Open

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

soernt opened this issue Feb 1, 2016 · 1 comment

Comments

@soernt
Copy link

soernt commented Feb 1, 2016

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.

@chrisriesgo
Copy link
Owner

@soernt - thanks for that suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants