Introduction

.NET MAUI is a powerful platform for building cross-platform mobile applications, and with the right tools and resources, it's easy to implement Avatar View into your App. This tutorial will walk you through the steps for adding Avatar View in .NET MAUI using .NET MAUI Community Toolkit.

Project Setup

Implementation

.NET MAUI Community Toolkit is the key to achieving drawing in our App is to use Community.ToolKit.Maui NuGet package. It is a collection of reusable elements such as animations, behavior converters, and among others, for developing applications for iOS, Android, macOS, and WinUI using MAUI.

Install .NET MAUI Community Toolkit

The complete code is given below.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
             x:Class="MauiAvatarView.MainPage"
             BackgroundColor="Black">

    <ScrollView>
        <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

            <toolkit:AvatarView Text="AM"
                                FontSize="30"
                      TextColor="White"
                      BackgroundColor="Green"
                      BorderColor="White"
                      BorderWidth="5" 
                      HeightRequest="150"
                      WidthRequest="150"                                
                    CornerRadius="120"
                                ImageSource="dotnet_bot.png"/>

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>

You can download the code from GitHub. If you have any doubts, feel free to post a comment. If you liked this article and it is useful, do like and share it.