Loading...
Loading...
Guide for implementing the Syncfusion WinUI AvatarView control to display user avatars and profile pictures. Use this when implementing user profiles, contact lists, or chat interfaces requiring visual user representation in WinUI applications. This skill covers initials display, image avatars, group avatars, and pre-defined avatar characters.
npx skill4agent add syncfusion/winui-ui-components-skills syncfusion-winui-avatar-viewSyncfusion.UI.Xaml.CoreSyncfusion.Core.WinUI<Page
xmlns:syncfusion="using:Syncfusion.UI.Xaml.Core">
<Grid>
<!-- Initials avatar -->
<syncfusion:SfAvatarView
x:Name="userAvatar"
ContentType="Initials"
AvatarName="John Doe"
InitialsType="DoubleCharacter"
AvatarSize="Large"
Background="CornflowerBlue"
Foreground="White"
AvatarShape="Circle"/>
</Grid>
</Page>using Syncfusion.UI.Xaml.Core;
using Microsoft.UI;
// Create avatar with initials
SfAvatarView avatarView = new SfAvatarView
{
ContentType = AvatarContentType.Initials,
AvatarName = "John Doe",
InitialsType = AvatarInitialsType.DoubleCharacter,
AvatarSize = AvatarSize.Large,
Background = new SolidColorBrush(Colors.CornflowerBlue),
Foreground = new SolidColorBrush(Colors.White),
AvatarShape = AvatarShape.Circle
};
// Add to UI
this.Content = avatarView;<syncfusion:SfAvatarView
ContentType="Initials"
AvatarName="Sarah Johnson"
InitialsType="DoubleCharacter"
AvatarSize="ExtraLarge"
AvatarShape="Circle"
Background="#FF6A5ACD"
Foreground="White"/><ListView ItemsSource="{x:Bind Contacts}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:Contact">
<StackPanel Orientation="Horizontal" Spacing="10">
<syncfusion:SfAvatarView
ContentType="CustomImage"
ImageSource="{x:Bind ProfileImagePath}"
AvatarSize="Medium"
AvatarShape="Circle"/>
<TextBlock Text="{x:Bind Name}" VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView><StackPanel Orientation="Horizontal" Spacing="10">
<syncfusion:SfAvatarView
ContentType="AvatarCharacter"
AvatarCharacter="Avatar15"
AvatarSize="Small"
AvatarShape="Circle"/>
<Border Background="LightGray"
CornerRadius="8"
Padding="10">
<TextBlock Text="Hello! How are you?"/>
</Border>
</StackPanel><syncfusion:SfAvatarView
ContentType="Group"
GroupSource="{x:Bind TeamMembers}"
ImageSourceMemberPath="ProfileImage"
InitialsMemberPath="Name"
BackgroundColorMemberPath="BackgroundColor"
InitialsColorMemberPath="InitialsColor"
AvatarSize="Large"/>public class TeamMember
{
public string Name { get; set; }
public string ProfileImage { get; set; }
public Color BackgroundColor { get; set; }
public Color InitialsColor { get; set; }
}
public ObservableCollection<TeamMember> TeamMembers { get; set; } = new()
{
new TeamMember { ProfileImage = "user1.png" },
new TeamMember { Name = "Alex", BackgroundColor = Colors.LightBlue, InitialsColor = Colors.Navy },
new TeamMember { ProfileImage = "user3.png" }
};private void ConfigureAvatar(User user)
{
if (!string.IsNullOrEmpty(user.ProfileImageUrl))
{
// Use custom image if available
avatarView.ContentType = AvatarContentType.CustomImage;
avatarView.ImageSource = new BitmapImage(new Uri(user.ProfileImageUrl));
}
else if (!string.IsNullOrEmpty(user.FullName))
{
// Use initials if no image
avatarView.ContentType = AvatarContentType.Initials;
avatarView.AvatarName = user.FullName;
avatarView.InitialsType = AvatarInitialsType.DoubleCharacter;
avatarView.Background = GetColorFromName(user.FullName);
}
else
{
// Use default avatar character
avatarView.ContentType = AvatarContentType.AvatarCharacter;
avatarView.AvatarCharacter = AvatarCharacter.Avatar1;
}
}<syncfusion:SfAvatarView
ContentType="CustomImage"
ImageSource="AppIcon.png"
AvatarShape="Square"
AvatarSize="Large"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="8"/><syncfusion:SfAvatarView
ContentType="Initials"
AvatarName="Emma Wilson"
InitialsType="DoubleCharacter"
AvatarSize="Large"
Foreground="White">
<syncfusion:SfAvatarView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="#FF6B5ACD" Offset="0"/>
<GradientStop Color="#FF4169E1" Offset="1"/>
</LinearGradientBrush>
</syncfusion:SfAvatarView.Background>
</syncfusion:SfAvatarView>| Property | Type | Default | Description |
|---|---|---|---|
| AvatarContentType | Default | Type of content to display. Options: Default, Initials, CustomImage, AvatarCharacter, Group. |
| ImageSource | null | Custom image for CustomImage content type. Path to user's profile picture. |
| string | null | Name to generate initials from. Used with Initials content type. |
| AvatarCharacter | Avatar1 | Pre-defined avatar character (Avatar1-Avatar25). Used with AvatarCharacter content type. |
| AvatarInitialsType | SingleCharacter | How initials are formatted. Options: SingleCharacter (first letter), DoubleCharacter (two letters). |
| AvatarShape | Circle | Visual shape. Options: Circle, Square, Custom. |
| AvatarSize | Small | Pre-defined size. Options: ExtraSmall, Small, Medium, Large, ExtraLarge. |
| IEnumerable | null | Collection for Group content type. Supports up to 3 items. |
| string | null | Property path for initials in GroupSource items. |
| string | null | Property path for image in GroupSource items. |
| string | null | Property path for background color in GroupSource items. |
| string | null | Property path for initials color in GroupSource items. |
| Brush | Gray | Background color or gradient for the avatar. |
| Brush | Black | Text color for initials. |
| Brush | null | Border color around the avatar. |
| Thickness | 0 | Border thickness around the avatar. |
| CornerRadius | Auto | Corner radius for Custom shape. |
| FontFamily | Segoe UI | Font for initials text. |
| double | Auto | Font size for initials (auto-calculated based on AvatarSize). |
Background="{ThemeResource SystemAccentColor}"