I have a carouselView with images and i want to bind each image source property to a list of strings inside carouselView .
class Class1 { public List<string> imageURL { get; set; } public Class1() { imageURL = new List<string>() { "imgg1.jpg", "imgg10.jpg", "imgg11.jpg", }; } } public MainPage() { InitializeComponent(); Class1 class1 = new Class1(); CarouselView carouselView = new CarouselView(); carouselView.BindingContext = class1; carouselView.ItemsSource = class1.imageURL; carouselView.ItemTemplate = new DataTemplate(() => { StackLayout stackLayout = new StackLayout(); Image image = new Image(); image.SetBinding(Image.SourceProperty, new Binding());
How to write properly the above SetBinding() function? For the first parameter Image.SourceProperty everything is clear, but for the second not really.
stackLayout.Children.Add(image); return stackLayout; }); s1.Children.Add(carouselView); }