Skip to content

Commit 853d4a7

Browse files
author
Ewaldjebaraj
committed
Update README.md
1 parent 597a24f commit 853d4a7

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,35 @@ The .NET MAUI single character initial view can be achieved using the `SingleCha
1313
The following code sample is an example for .NET MAUI Initials View with single character.
1414

1515
**XAML**
16-
16+
```
1717
<sfAvatar:SfAvatarView ContentType="Initials"
1818
InitialsType="SingleCharacter" >
1919
</sfAvatar:SfAvatarView>
20+
```
2021

2122
### .NET MAUI Double Character Initials View
2223
The .NET MAUI double character initial view can be achieved using the `DoubleCharacter` option of the `InitialsType` property of the SfAvatarView.
2324
The following code sample is an example for .NET MAUI Initials View with double characters.
2425

2526
**XAML**
2627

28+
```
2729
<sfAvatar:SfAvatarView ContentType="Initials"
2830
InitialsType="DoubleCharacter" >
2931
</sfAvatar:SfAvatarView>
32+
```
3033

3134
## Steps to add .NET MAUI Initials View
3235
This section explains how to create a contact list with initials view with a double character in a .NET MAUI application.
36+
3337
**Step 1**: Create a .NET MAUI application project in Visual Studio 2022.
38+
3439
**Step 2**: Add the [Syncfusion.Maui.Core](https://www.nuget.org/packages/Syncfusion.Maui.Core/) Nuget to the project from [nuget.org](https://www.nuget.org/).
40+
3541
**Step 3**: In the MauiProgram.cs file, register the Syncfusion.Maui.Core handler as follows.
3642

3743
**C#**
44+
```
3845
3946
using Syncfusion.Maui.Core.Hosting;
4047
namespace AvatarView_ContactList;
@@ -55,23 +62,23 @@ public static class MauiProgram
5562
return builder.Build();
5663
}
5764
}
58-
65+
```
5966

6067
**Step 4**: Add the .NET MAUI Avatar View control namespace to the MainPage.xaml.
6168

6269
**XAML**
63-
70+
```
6471
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
6572
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6673
x:Class="AvatarView_ContactList.MainPage"
6774
xmlns:sfAvatar="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
6875
xmlns:local="clr-namespace:AvatarView_ContactList">
6976
70-
77+
```
7178
**Step 5**: Create a list of contact details in the view model. Have a property Name that holds the value to be shown as in the .NET MAUI Initials View.
7279

7380
**C#**
74-
81+
```
7582
public class Contact
7683
{
7784
public string Name { get; set; }
@@ -97,13 +104,13 @@ public class ContactsViewModel
97104
ListOfContacts.Add(new Contact() { Name = "Logan James" });
98105
}
99106
}
100-
107+
```
101108

102109
**Step 6**: Define the Avatar View (SfAvatarView) in the XAML and set the `ContentType` as `Initials` and set the `InitialType` property as `DoubleCharacter`. To create initials for the contact in the .NET MAUI Avatar View, populate the contact list in the collection view and bind the contact’s name to the `AvatarName` property.
103110
This will display the Avatar View as Initials View in a circle shape.
104111

105112
**XAML**
106-
113+
```
107114
<ContentPage.BindingContext>
108115
<local:ContactsViewModel/>
109116
</ContentPage.BindingContext>
@@ -129,7 +136,7 @@ This will display the Avatar View as Initials View in a circle shape.
129136
</CollectionView.ItemTemplate>
130137
</CollectionView>
131138
</Grid>
132-
139+
```
133140

134141
You can explore the runnable demo of achieving the .NET MAUI Initials View in this repository
135142

0 commit comments

Comments
 (0)