I have been working with CarouselView
while using the Nuget Package Xamarin.Forms.CarouselView
. I have tried to display the images as auto sliding.
XAML
<StackLayout Grid.Row="0" Grid.ColumnSpan="4">
<cv:CarouselView x:Name="MainCarouselView" Position="{Binding PositionIndex, Mode=TwoWay}">
<cv:CarouselView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding .}"></Image>
</DataTemplate>
</cv:CarouselView.ItemTemplate>
</cv:CarouselView >
</StackLayout>
C#
var image = new ObservableCollection<ImageSource>
{
ImageSource.FromFile("Image1.jpg"),
ImageSource.FromFile("Image2.jpg"),
ImageSource.FromFile("Image3.jpg")
};
MainCarouselView.ItemsSource = image;
Device.StartTimer(TimeSpan.FromSeconds(2), (Func<bool>) (() =>
{
MainCarouselView.Position = (MainCarouselView.Position + 1) % image.Count;
return true;
}));
After running the app on the device or emulator I get this error:
Severity Code Description Project File Line Suppression State Error CS0433 The type 'CarouselView' exists in both 'Xamarin.Forms.CarouselView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'
I have tried to delete the Nuget Package and tried then the CarouselView
remains empty and it also does not contain the property of Position
. Any help will be appreciated.
EDIT: I have solved using CarouselView.FormsPlugin Xaml:
<controls:CarouselViewControl x:Name="MainCarouselView" Grid.Row="0" Grid.ColumnSpan="3" Position="{Binding PositionIndex, Mode=TwoWay}">
<controls:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding .}"></Image>
</DataTemplate>
</controls:CarouselViewControl.ItemTemplate>
</controls:CarouselViewControl >
And kept the cs code same. Thanks for the help guys.