How to add a .NET MAUI circle image to the user profile using Avatar View (SfAvatarView)?
The .NET MAUI AvatarView provides a graphical representation of the user profile image that allows you to customize the view by adding a circle image, background color, icon, text, and more. The .NET MAUI circle image can be achieved using the SfAvatarView control with the avatar shape as a circle.
Steps to add .NET MAUI Circle Image
This section explains how to add a .NET MAUI circle image to the user profile using the SfAvatarView control.
Step 1: Create a .NET MAUI application project in Visual Studio 2022.
Step 2: Add the Syncfusion.Maui.Core Nuget to the project from nuget.org.
Step 3: In the MauiProgram.cs file, register the Syncfusion.Maui.Core handler as shown in the following code.
C#
using Syncfusion.Maui.Core.Hosting; namespace UserProfileSample; public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp<App>() .ConfigureSyncfusionCore() return builder.Build(); } }
Step 4: Add the Syncfusion.Maui.Core namespace to the MainPage.xaml.
XAML
xmlns:avatarview="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
Step 5: To add a .NET MAUI Circle Image in your .NET MAUI Application, define the SfAvatarView in the XAML and set the user image through the ImageSource property, set the AvatarShape property to the circle, render the profile image as a circle image, and add it to the user profile content page.
XAML
<ContentPage.Content> <Grid HorizontalOptions="Center" VerticalOptions="Center" RowSpacing="30"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <avatarview:SfAvatarView ContentType="Custom" ImageSource="scarlett_jhonsan.png" VerticalOptions="Center" HorizontalOptions="Center" HeightRequest="100" WidthRequest="100" CornerRadius="50" /> <Grid Grid.Row="1" ColumnSpacing="30" RowSpacing="15" > <Grid.RowDefinitions> <RowDefinition Height="35"/> <RowDefinition Height="35"/> <RowDefinition Height="35"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="25"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Image Source="user.png" HeightRequest="25" VerticalOptions="Center"/> <Image Grid.Row="1" Source="call.png" HeightRequest="22" VerticalOptions="Center"/> <Image Grid.Row="2" Source="mail.png" HeightRequest="20" VerticalOptions="Center" /> <Label VerticalOptions="Start" Grid.Column="1" Text="Name" TextColor="Gray" FontSize="12"/> <Label VerticalOptions="End" Grid.Column="1" Text="Scarlett Jhonsan" FontAttributes="Bold"/> <Label VerticalOptions="Start" Grid.Row="1" Grid.Column="1" Text="Phone" TextColor="Gray" FontSize="12"/> <Label VerticalOptions="End" Grid.Row="1" Grid.Column="1" Text="+44 5674 4432" FontAttributes="Bold"/> <Label VerticalOptions="Start" Grid.Row="2" Grid.Column="1" Text="Mail" TextColor="Gray" FontSize="12"/> <Label VerticalOptions="End" Grid.Row="2" Grid.Column="1" Text="scarlettjhonsan99@gmail.com" FontAttributes="Bold"/> </Grid> </Grid> </ContentPage.Content>
OUTPUT:
Also, another way to add .NET MAUI Circle Image in your .NET MAUI Application, define the SfAvatarView in the XAML and set the user image through the ImageSource property, set the CornerRadius property to render the profile image as a circle image.
Download the complete sample on GitHub
Conclusion
Hope you enjoyed learning about how to add a .NET MAUI circle image to the user profile using Avatar View (SfAvatarView).
You can refer to our .NET MAUI Avatar View’s feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Avatar View documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our .NET MAUI Avatar View and other .NET MAUI components.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!