UIVirtualization support to handle the numerous data in Xamarin.iOS Carousel
Carousel control can handle the numerous data using UI virtualization by maintaining only the view port items into it.
Properties are used to achieve UI Virtualization options
Properties | Data Type | Default Value | Usage |
EnableVirtualization
| Boolean | false | Enable or disable UI Virtualization options in carousel control |
ItemsSource | IEnumerable | null | To load the collection of data’s |
DrawView event is used to pass the custom view into your carousel view. It holds the following arguments
- Index – Gets the indexed of carousel item.
- View – Gets and Sets the custom view of carousel’s item.
- Item – Gets the indexed carousel item.
The following code example illustrates the way to use the UI Virtualization feature on carousel control.
In ViewDidLoad:
C#
public override void ViewDidLoad() { base.ViewDidLoad(); SFCarousel sFCarousel = new SFCarousel(); sFCarousel.Frame = new CoreGraphics.CGRect(0, 150, 400, 400); ObservableCollection<string> list = new ObservableCollection<string>(); for (int i = 1; i < 100000; i++) { list.Add("Item " + i.ToString()); } sFCarousel.ItemWidth = 150; sFCarousel.ItemHeight = 150; sFCarousel.EnableVirtualization = true; sFCarousel.ViewMode = SFCarouselViewMode.SFCarouselViewModeLinear; sFCarousel.ItemsSource = list; sFCarousel.DrawView+=(object sender, DrawViewEventArgs e) => { UIView carouselView = new UIView(); carouselView.BackgroundColor = UIColor.Red; carouselView.Frame = new CoreGraphics.CGRect(0, 0, 150, 150); UILabel iconLabel = new UILabel(); iconLabel.Frame = new CoreGraphics.CGRect(35, 30, 80, 80); iconLabel.Text = (sFCarousel.ItemsSource as ObservableCollection<string>)[e.Index]; iconLabel.TextColor = UIColor.White; iconLabel.TextAlignment = UITextAlignment.Center; carouselView.AddSubview(iconLabel); e.View = carouselView; }; View.AddSubview(sFCarousel); // Perform any additional setup after loading the view, typically from a nib. }
Sample:
Conclusion
I hope you enjoyed learning about UIVirtualization support to handle the numerous data in Carousel.
You can refer to our Xamarin.iOS Carousel feature tour page to know about its other groundbreaking feature
representations and documentation, and how
to quickly get started for configuration specifications. You can also
explore our Xamarin.iOS Carousel example
to understand
how to create and manipulate data.
For current customers, you can check out
our components from the License and Downloads page. If you are new to Syncfusion, you can try our
30-day free
trial
to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!