Populating DataSource
5 Jun 2020 / 1 minute to read
DataSource with Collection of Images
SfCarousel items can be populated with a collection of business objects. For example, a user may wants to create a SfCarousel control which will display a list of images.
NSMutableArray<SfCarouselItem> carouselItemCollection = new NSMutableArray<SfCarouselItem> ();
for(int i=1;i<18;i++)
{
SfCarouselItem item = new SfCarouselItem();
item.ImageName = "image"+i+".png";
carouselItemCollection.Add(item);
}
carousel.DataSource = carouselItemCollection;
DataSource with Collection of custom view
SfCarousel items can be populated with a collection of business objects. It can be achieved by passing the custom view into View property in SfCarouselItem
SfCarousel carousel = new SfCarousel();
NSMutableArray<SfCarouselItem> listOfArray = new NSMutableArray<SfCarouselItem>();
for (int i = 1; i < 4; i++)
{
SfCarouselItem items = new SfCarouselItem();
UIImageView uiImageView = new UIImageView();
uiImageView.Frame = new CGRect(0, 0, carousel.ItemWidth, carousel.ItemHeight);
uiImageView.Image = new UIImage("Images/image"+i.ToString()+".png");
items.View = uiImageView;
listOfArray.Add(items);
}
carousel.DataSource = listOfArray;
View.AddSubview(carousel);
Carousel SelectedIndex
It gets or sets the Selected Item index value of SfCarousel control to bring the particular item to center of the screen.
NOTE
The
SelectedIndex
property will be 0 by default.
carousel.SelectedIndex = 2;
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page