Skip to content

Commit f13cbe5

Browse files
authored
Updated the readme file
1 parent 66d5607 commit f13cbe5

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
11
# How-to-add-Header-and-Footer-support-in-DOTNET-MAUI-Autocomplete
2-
This repository contains a sample demonstrating of Header and Footer support in .NET MAUI Autocomplete.
2+
This repository contains a sample demonstrating Header and Footer support in .NET MAUI Autocomplete. We can achieve it by following the steps below,
3+
4+
**Step 1:** Initialize the Autocomplete control in the XAML page with all required assemblies.
5+
6+
**XAML:**
7+
```
8+
<editors:SfAutocomplete x:Name="autocomplete"/>
9+
```
10+
**Step 2:** Create the Model class with the properties that need to be assigned.
11+
12+
**C#:**
13+
**Model**
14+
```
15+
public class SocialMedia
16+
{
17+
public string Name { get; set; }
18+
public int ID { get; set; }
19+
}
20+
```
21+
**Step 3:** Create the ViewModel class and then populate social media data in the SocialMediaViewModel
22+
23+
**C#**
24+
**ViewModel**
25+
```
26+
public class SocialMediaViewModel
27+
{
28+
public ObservableCollection<SocialMedia> SocialMedias { get; set; }
29+
public SocialMediaViewModel()
30+
{
31+
this.SocialMedias = new ObservableCollection<SocialMedia>();
32+
this.SocialMedias.Add(new SocialMedia() { Name = "Facebook", ID = 0 });
33+
this.SocialMedias.Add(new SocialMedia() { Name = "Google Plus", ID = 1 });
34+
this.SocialMedias.Add(new SocialMedia() { Name = "Instagram", ID = 2 });
35+
this.SocialMedias.Add(new SocialMedia() { Name = "LinkedIn", ID = 3 });
36+
this.SocialMedias.Add(new SocialMedia() { Name = "Skype", ID = 4 });
37+
this.SocialMedias.Add(new SocialMedia() { Name = "Telegram", ID = 5 });
38+
this.SocialMedias.Add(new SocialMedia() { Name = "Televzr", ID = 6 });
39+
this.SocialMedias.Add(new SocialMedia() { Name = "Tik Tok", ID = 7 });
40+
this.SocialMedias.Add(new SocialMedia() { Name = "Tout", ID = 8 });
41+
this.SocialMedias.Add(new SocialMedia() { Name = "Tumblr", ID = 9 });
42+
this.SocialMedias.Add(new SocialMedia() { Name = "Twitter", ID = 10 });
43+
this.SocialMedias.Add(new SocialMedia() { Name = "Vimeo", ID = 11 });
44+
this.SocialMedias.Add(new SocialMedia() { Name = "WhatsApp", ID = 12 });
45+
this.SocialMedias.Add(new SocialMedia() { Name = "YouTube", ID = 13 });
46+
}
47+
}
48+
```
49+
**Step 4:** Initialize the Autocomplete control in the XAML page in which the ViewModel class is set to the BindingContext.
50+
```
51+
<editors:SfAutocomplete HeightRequest="40"
52+
WidthRequest="300"
53+
MaxDropDownHeight="200"
54+
ItemsSource="{Binding SocialMedias}"
55+
ShowDropdownHeaderView="True"
56+
DisplayMemberPath="Name"
57+
DropdownHeaderViewHeight="50"
58+
Margin="50">
59+
<editors:SfAutocomplete.DropdownHeaderView>
60+
<StackLayout BackgroundColor="#f0f0f0" >
61+
<Label FontSize="20" Text="Header View" TextColor="Red" />
62+
</StackLayout>
63+
</editors:SfAutocomplete.DropdownHeaderView>
64+
</editors:SfAutocomplete>
65+
66+
<editors:SfAutocomplete HeightRequest="40"
67+
WidthRequest="300"
68+
MaxDropDownHeight="200"
69+
ItemsSource="{Binding SocialMedias}"
70+
ShowDropdownFooterView="True"
71+
DisplayMemberPath="Name"
72+
DropdownFooterViewHeight="50">
73+
<editors:SfAutocomplete.DropdownFooterView>
74+
<StackLayout BackgroundColor="#f0f0f0" >
75+
<Label FontSize="20" Text="Footer View" TextColor="Red" />
76+
</StackLayout>
77+
</editors:SfAutocomplete.DropdownFooterView>
78+
</editors:SfAutocomplete>
79+
```

0 commit comments

Comments
 (0)