Category / Section
How to get the SelectedIndex in SfRotator
1 min read
Steps to get the SelectedIndex in SfRotator:
Step 1: Add items to rotator using SfRotatorItem.
Step 2: Use the selected index property or e.Index in the selection changed event to get selectedindex of the current SfRotator item.
The following code demonstrates how to get the selectedindex in SfRotator.
namespace RotatorTestApp { public partial class ViewController : UIViewController { SfRotator rotator; NSMutableArray collection; UILabel indexLabel; public ViewController (IntPtr handle) : base (handle) { } public override void ViewDidLoad () { base.ViewDidLoad (); collection = new NSMutableArray(); indexLabel = new UILabel(); indexLabel.Frame = new CGRect(10,340,this.View.Frame.Width,60); rotator = new SfRotator(); rotator.Frame = new CGRect(0,10,this.View.Frame.Width,300); indexLabel.Text = "Rotator SelectedIndex is: 0"; for (int i = 0;i<5;i++) { SfRotatorItem item = new SfRotatorItem(); item.View = new UILabel() { Frame = rotator.Frame, Text = "SfRotatorItem " + i }; collection.Add(item); } rotator.DataSource = collection; rotator.SelectionChanged += Rotator_SelectionChanged; this.Add(rotator); this.Add(indexLabel); } private void Rotator_SelectionChanged(object sender, SelectionChangedEventArgs e) { indexLabel.Text = "Rotator SelectedIndex is: " + rotator.SelectedIndex;//e.Index also can be used } } }
Sample image to show the SfRotator Selected index
Please find the sample from the below link:
https://www.syncfusion.com/downloads/support/forum/139462/ze/RotatorTestApp-1580215678