Getting started of .NET MAUI Shimmer (SfShimmer)

16 Apr 20246 minutes to read

This section explains how to add the Shimmer control.

To get start quickly with our .NET MAUI Shimmer, you can check the below video.

Creating an application using the .NET MAUI Shimmer

  1. Create a new .NET MAUI application in Visual Studio.

  2. Syncfusion .NET MAUI components are available on nuget.org. To add SfShimmer to your project, open the NuGet package manager in Visual Studio, and search for the Syncfusion.Maui.Core, and then install it.
  3. To initialize the control, import the control namespace Syncfusion.Maui.Shimmer in XAML or C# code.

  4. Initialize SfShimmer.
<ContentPage   
    . . .
    xmlns:shimmer="clr-namespace:Syncfusion.Maui.Shimmer;assembly=Syncfusion.Maui.Core">

    <shimmer:SfShimmer />
</ContentPage>
using Syncfusion.Maui.Shimmer;
. . .

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        SfShimmer shimmer = new SfShimmer();
        this.Content = shimmer;
    }
}

Register the handler

The Syncfusion.Maui.Core NuGet is a dependent package for all Syncfusion controls of .NET MAUI. In the MauiProgram.cs file, register the handler for Syncfusion core.

using Syncfusion.Maui.Core.Hosting;
namespace GettingStarted
{
    public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();

            builder.ConfigureSyncfusionCore();
            builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("Segoe-mdl2.ttf", "SegoeMDL2");
            });

            return builder.Build();
        }
    }
}

Change different shimmer views

The .NET MAUI Shimmer control provides seven different shimmer types of views. It can be assigned to the control using the Type property. By default, the control is assigned to the CirclePersona view.

<shimmer:SfShimmer x:Name="Shimmer" VerticalOptions="Fill"
                   Type="CirclePersona">
    <StackLayout>
        <Label
            Text="Content is loaded!"
            HorizontalOptions="CenterAndExpand"
            VerticalOptions="CenterAndExpand">
        </Label>
    </StackLayout>
</shimmer:SfShimmer>
SfShimmer shimmer = new SfShimmer()
   {
      Type = ShimmerType.CirclePersona,
      VerticalOptions = LayoutOptions.Fill,
      Content = new Label
      {
         Text = "Content is loaded!!"
      }
   };

   this.Content = shimmer;

Circle persona shimmer view in .NET MAUI.

Loading shimmer content

Shimmer content is loaded when the IsActive property of the SfShimmer is disabled.

<shimmer:SfShimmer x:Name="shimmer" VerticalOptions="FillAndExpand" IsActive ="false">
                <shimmer:SfShimmer.Content>
                     <StackLayout>
                        <Label Text="Content is loaded!"/>
                      </StackLayout>
                </shimmer:SfShimmer.Content>
        </shimmer:SfShimmer>
shimmer = new SfShimmer()
            {
                IsActive = false,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Content = new Label
                {
                    Text = "Content is loaded!"
                }
            };
            this.Content = shimmer;

NOTE

You can refer to our .NET MAUI Shimmer feature tour page for its groundbreaking feature representations. You can also explore our .NET MAUI Shimmer Example that shows you how to render the Shimmer in .NET MAUI.