Looping in Xamarin.Android

10 Apr 20201 minute to read

The Looping support is used to automatically navigate the first item to repeat the list of items after reached the last item. Each forward iteration is followed by a backward iteration in the picker control. This can be achieved by EnableLooping property.

EnableLooping

The looping support is achieved by setting the EnableLooping property to true.

  • C#
  • SfPicker picker = new SfPicker();
    
    ColorInfo info = new ColorInfo();
    
    picker.ItemsSource = info.Colors;
    
    // Enable Looping in picker control
    
    picker.EnableLooping = true;

    Screen shot for the above codes.

    Looping

    You can find the complete Looping sample from this link.

    How to restrict Looping in a particular column of the picker

    The looping support can be restricted in a particular column of the picker by setting the EnableLooping of ColumnLoaded event argument to false.

  • C#
  • picker.OnColumnLoaded+=(object sender, ColumnLoadedEventArgs e) => 
    {
    
    if (e.Column == 0)
    {
        e.EnableLooping = true;
    }
    else
        e.EnableLooping = false;
    };

    Screen shot for the above codes.

    Looping

    You can find the sample from this link.