-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBottomSheetWithSearchViewModel.cs
More file actions
40 lines (34 loc) · 1 KB
/
BottomSheetWithSearchViewModel.cs
File metadata and controls
40 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Windows.Input;
using Components.SampleData;
using DIPS.Mobile.UI.MVVM;
namespace Components.ComponentsSamples.BottomSheets.Sheets;
public class BottomSheetWithSearchViewModel : ViewModel
{
private List<Person> m_people;
private readonly List<Person> m_originalPeople;
public BottomSheetWithSearchViewModel()
{
People = SampleDataStorage.People.ToList();
m_originalPeople = People.ToList();
SearchCommand = new Command<string>(FilterItems);
}
private void FilterItems(string filterText)
{
if (string.IsNullOrEmpty(filterText))
{
People = m_originalPeople.ToList();
}
else
{
People = m_originalPeople
.Where(p => p.DisplayName.ToLower().Contains(filterText.ToLower()))
.ToList();
}
}
public List<Person> People
{
get => m_people;
set => RaiseWhenSet(ref m_people, value);
}
public ICommand SearchCommand { get; }
}