You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-8Lines changed: 15 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -13,28 +13,35 @@ The .NET MAUI single character initial view can be achieved using the `SingleCha
13
13
The following code sample is an example for .NET MAUI Initials View with single character.
14
14
15
15
**XAML**
16
-
16
+
```
17
17
<sfAvatar:SfAvatarView ContentType="Initials"
18
18
InitialsType="SingleCharacter" >
19
19
</sfAvatar:SfAvatarView>
20
+
```
20
21
21
22
### .NET MAUI Double Character Initials View
22
23
The .NET MAUI double character initial view can be achieved using the `DoubleCharacter` option of the `InitialsType` property of the SfAvatarView.
23
24
The following code sample is an example for .NET MAUI Initials View with double characters.
24
25
25
26
**XAML**
26
27
28
+
```
27
29
<sfAvatar:SfAvatarView ContentType="Initials"
28
30
InitialsType="DoubleCharacter" >
29
31
</sfAvatar:SfAvatarView>
32
+
```
30
33
31
34
## Steps to add .NET MAUI Initials View
32
35
This section explains how to create a contact list with initials view with a double character in a .NET MAUI application.
36
+
33
37
**Step 1**: Create a .NET MAUI application project in Visual Studio 2022.
38
+
34
39
**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
+
35
41
**Step 3**: In the MauiProgram.cs file, register the Syncfusion.Maui.Core handler as follows.
36
42
37
43
**C#**
44
+
```
38
45
39
46
using Syncfusion.Maui.Core.Hosting;
40
47
namespace AvatarView_ContactList;
@@ -55,23 +62,23 @@ public static class MauiProgram
55
62
return builder.Build();
56
63
}
57
64
}
58
-
65
+
```
59
66
60
67
**Step 4**: Add the .NET MAUI Avatar View control namespace to the MainPage.xaml.
**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.
72
79
73
80
**C#**
74
-
81
+
```
75
82
public class Contact
76
83
{
77
84
public string Name { get; set; }
@@ -97,13 +104,13 @@ public class ContactsViewModel
97
104
ListOfContacts.Add(new Contact() { Name = "Logan James" });
98
105
}
99
106
}
100
-
107
+
```
101
108
102
109
**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.
103
110
This will display the Avatar View as Initials View in a circle shape.
104
111
105
112
**XAML**
106
-
113
+
```
107
114
<ContentPage.BindingContext>
108
115
<local:ContactsViewModel/>
109
116
</ContentPage.BindingContext>
@@ -129,7 +136,7 @@ This will display the Avatar View as Initials View in a circle shape.
129
136
</CollectionView.ItemTemplate>
130
137
</CollectionView>
131
138
</Grid>
132
-
139
+
```
133
140
134
141
You can explore the runnable demo of achieving the .NET MAUI Initials View in this repository
0 commit comments