Articles in this section
Category / Section

How to use the ItemTemplate in the .NET MAUI Rotator?

2 mins read

This section explains how to use the ItemTemplate in the .NET MAUI Rotator. You can achieve it by following these steps:

Step 1: Create Model and ViewModel classes in the sample.
Step 2: Create a list of collections in the ViewModel class and add the corresponding image value.
Step 3: Initialized the Rotator control in xaml page.
Step 4: Bind the list of collections into the Image property in ItemTemplate using a DataTemplate.

The following code demonstrates how to use the ItemTemplate in SfRotator.

XAML:

    <syncfusion:SfRotator 
                x:Name="rotator"
                ItemsSource="{Binding ImageCollection}">

        <syncfusion:SfRotator.ItemTemplate>
            <DataTemplate>
                <Image Source="{Binding Image}"/>
            </DataTemplate>
        </syncfusion:SfRotator.ItemTemplate>
    </syncfusion:SfRotator>

C#:

 public class RotatorModel
 {
     public RotatorModel(string image)
     {
         Image = image;
     }
     private string _image;
     public string Image
     {
         get { return _image; }
         set { _image = value; }
     }
 }

 public class RotatorViewModel
 {
     public RotatorViewModel()
     {
         ImageCollection.Add(new RotatorModel("image1.png"));
         ImageCollection.Add(new RotatorModel("image2.png"));
         ImageCollection.Add(new RotatorModel("image3.png"));
         ImageCollection.Add(new RotatorModel("image4.png"));
         ImageCollection.Add(new RotatorModel("image5.png"));
     }
     private List<RotatorModel> imageCollection = new List<RotatorModel>();
     public List<RotatorModel> ImageCollection
     {
         get { return imageCollection; }
         set { imageCollection = value; }
     }
 }

Output:

qemu-system-x86_64_rzImfNOH39-ezgif.com-video-to-gif-converter.gif

Conclusion:
I hope you enjoyed learning how to use the ItemTemplate in the Rotator.

Refer to our .NET MAUI Rotator feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Rotator documentation to understand how to present and manipulate data.

For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to explore our .NET MAUI Rotator and other .NET MAUI components.

Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal, or the feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied