Articles in this section
Category / Section

How to load images from Internet in .NET MAUI Rotator (SfRotator)?

3 mins read

This document explains how to add images from internet in .NET MAUI Rotator. We can achieve it by following the below steps,

Step 1: Initialize the Rotator control in xaml page with all required assemblies.

XAML:

<syncfusion:SfRotator x:Name="rotator"/>

Step 2: Create the Model class with the properties need to be assigned.

C#:

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

Step 3: Create the ViewModel class and add image collection of URL that needs to be bound with the data source.

C#

 public class RotatorViewModel
 {
     public RotatorViewModel()
     {
         ImageCollection.Add(new RotatorModel("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQe0ub78kIqvmA13W9Sr6VdDcu0ciXwScvgKgDKQuitqLAQoUxJng"));
         ImageCollection.Add(new RotatorModel("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ-6rRDNIfS0JE47sDceHbY4FkY15Hl88OOzC_BFIRWcawLlIsk"));
         ImageCollection.Add(new RotatorModel("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRSgxX4vNJToErxuEprfne9xvIOkLO262VfYNcDm5iCGnagzJDs"));
         ImageCollection.Add(new RotatorModel("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSsIYs-RihLWXHvr6tqkOVxaRvjBqIUZpqH6_gJD0spZbB46rSRfQ"));
         ImageCollection.Add(new RotatorModel("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRTCkvGBaNwtSdkefoj_2QLYK4KRwHNH6hgaPIwXf2cqd1AN_CG"));
     }
     private List<RotatorModel> imageCollection = new List<RotatorModel>();
     public List<RotatorModel> ImageCollection
     {
         get { return imageCollection; }
         set { imageCollection = value; }
     }
 }
 

Step 4: Initialize the Rotator control in XAML page in which the ViewModel class set to BindingContext.

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

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

Output:

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

You can download the complete sample in GitHub

Conclusion:
I hope you enjoyed learning how to load images from the internet in Rotator.

You can 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