SfCarousel - MovePrevious and MoveNext not working

SfCarousel's MovePrevious and MoveNext methods not work on UWP and give NullReferenceException and SelectedIndex is always 0, but it works fine on Android.

View :

<StackLayout>
<syncfusion:SfCarousel 
x:Name="MyCarousel"
ItemsSource="{Binding Images}"
ViewMode="Linear">
<syncfusion:SfCarousel.ItemTemplate>
<DataTemplate>
<Grid x:DataType="x:String">
<Image Source="{Binding}"/>
</Grid>
</DataTemplate>
</syncfusion:SfCarousel.ItemTemplate>
</syncfusion:SfCarousel>
<Button Text="Previous" Clicked="Previous_OnClicked"/>
<Button Text="Next" Clicked="Next_OnClicked"/>
</StackLayout>


Code Behind :

private void Previous_OnClicked(object sender, EventArgs e)
{
    MyCarousel.MovePrevious();
}

private void Next_OnClicked(object sender, EventArgs e)
{
    MyCarousel.MoveNext();

    // index is always = 0 on UWP
    var index = MyCarousel.SelectedIndex;
}

1 Reply

PA Paul Anderson S Syncfusion Team September 27, 2018 12:22 PM UTC

Hi Moien, 
 
Greetings from Syncfusion. 
 
We could reproduce the issue "MoveNext and MovePrevious method in SfCarousel is not working" at our end. We will fix this issue and it will be available in our next Volume 3 Service pack 1 (October 2018). 
 
For the same we have prepared a workaround in sample. Please use the sample code given below. 
 
public void NextClick(object sender,EventArgs e) 
        { 
            if(carousel.SelectedIndex < carousel.ItemsSource.Count()) 
            { 
                carousel.SelectedIndex = carousel.SelectedIndex + 1; 
            } 
        } 
 
        public void PreviouosClick(object sender, EventArgs e) 
        { 
            if (carousel.SelectedIndex < carousel.ItemsSource.Count() && carousel.SelectedIndex >= 0) 
            { 
                carousel.SelectedIndex = carousel.SelectedIndex - 1; 
            } 
        } 
 
 
Please download the sample from the link given below. 
 
 
Please let us know if you have further assistance about this. 
 
Regards, 
Paul Anderson 


Loader.
Up arrow icon