Closed InquisitorJax closed 3 years ago
Hey @InquisitorJax after investigation I realized that it's is not supposed to be workin in non TwoWay binding mode. Because of SelectedIndex is set by CardsView what causes clearing your binding (cuz it's not TwoWay).
if you wish, I can expose additional command property NavigateToCommand + NavigateTo method (so you will be able to call this command with desired index and that index will be set to SelectedIndex)
Would the property change event that's fired for SelectedIndex not be the same as a request for NavigateTo? I could probably work around the issue by not updating other bindings when SelectedIndex property changes - I'll give that a try. I think there'll be an expectation for SelectedIndex to work in both Binding Modes - if that's really not possible, you should probably mention something about that in the documentation / readme.
Just leaving the explanation here: TwoWay binding wasn't working for us, because on Android CarouselView would set SelectedIndex halfway through the swipe animation. We were setting a SelectedItem property in the setter of SelectedIndex ViewModel property - which other UI elements are bound to. This was causing the swipe animation not to be smooth as the other UI updates would take up CPU cycles on the UI thread. Since SelectedIndex OneWay does not work as expected - we reverted back to TwoWay binding (which works great!), and just removed the SelectedItem code logic from the setter of SelectedIndex ViewModel property, and updated that separately. We update the SelectedItem from user swiping by hooking into the ItemAppeared event - which fires after the swipe animation has completed.
@InquisitorJax thanks for posting that :)
When setting SelectedIndex property binding mode to OneWay, the Carousel doesn't update it's position when the ViewModel property is set to a different value. One Way Binding:
TwoWay Binding (default):
CardsCarouselSample.zip