44
55namespace SimpleDataGrid . Example ;
66
7+ /// <summary>
8+ /// The main view model for the SimpleDataGrid example application.
9+ /// </summary>
710public class MainViewModel
811{
12+ /// <summary>
13+ /// Gets the paged collection of people.
14+ /// </summary>
915 public PagedCollection < Person > People { get ; }
16+ /// <summary>
17+ /// Gets a list of available page sizes.
18+ /// </summary>
1019 public List < int > PageSizes { get ; } = [ 10 , 25 , 50 , 100 ] ;
1120
21+ /// <summary>
22+ /// Gets or sets a value indicating whether to search by name.
23+ /// </summary>
1224 public bool SearchByName { get ; set ; } = true ;
25+ /// <summary>
26+ /// Gets or sets a value indicating whether to search by email.
27+ /// </summary>
1328 public bool SearchByEmail { get ; set ; } = false ;
29+ /// <summary>
30+ /// Gets or sets a value indicating whether to search by department.
31+ /// </summary>
1432 public bool SearchByDepartment { get ; set ; } = false ;
1533
34+ /// <summary>
35+ /// Initializes a new instance of the <see cref="MainViewModel"/> class.
36+ /// </summary>
1637 public MainViewModel ( )
1738 {
1839 People = new PagedCollection < Person > ( 10 ) ;
@@ -29,39 +50,79 @@ private static List<Person> GetPeople()
2950 return people ;
3051 }
3152
53+ /// <summary>
54+ /// Applies a minimum age filter to the people collection.
55+ /// </summary>
56+ /// <param name="minAge">The minimum age to filter by.</param>
3257 public void ApplyFilter ( int minAge )
3358 {
3459 People . SetFilter ( "minAge" , p => p . Age >= minAge ) ;
3560 }
3661
62+ /// <summary>
63+ /// Applies a maximum age filter to the people collection.
64+ /// </summary>
65+ /// <param name="maxAge">The maximum age to filter by.</param>
3766 public void ApplyMaxAgeFilter ( int maxAge )
3867 {
3968 People . SetFilter ( "maxAge" , p => p . Age <= maxAge ) ;
4069 }
4170
71+ /// <summary>
72+ /// Applies a name prefix filter to the people collection.
73+ /// </summary>
74+ /// <param name="namePrefix">The name prefix to filter by.</param>
4275 public void ApplyNameFilter ( string namePrefix )
4376 {
4477 People . SetFilter ( "namePrefix" , p => p . Name . StartsWith ( namePrefix , StringComparison . OrdinalIgnoreCase ) ) ;
4578 }
4679
80+ /// <summary>
81+ /// Removes a filter from the people collection.
82+ /// </summary>
83+ /// <param name="key">The key of the filter to remove.</param>
4784 public void RemoveFilter ( string key )
4885 {
4986 People . RemoveFilter ( key ) ;
5087 }
5188
89+ /// <summary>
90+ /// Gets a read-only collection of the active filter keys.
91+ /// </summary>
5292 public IReadOnlyCollection < string > ActiveFilters => People . GetActiveFilters ( ) ;
5393
94+ /// <summary>
95+ /// Clears all filters from the people collection.
96+ /// </summary>
5497 public void ClearFilter ( )
5598 {
5699 People . ClearFilters ( ) ;
57100 }
58101}
59102
103+ /// <summary>
104+ /// Represents a person with basic information.
105+ /// </summary>
60106public class Person
61107{
108+ /// <summary>
109+ /// Gets or sets the unique identifier of the person.
110+ /// </summary>
62111 public int Id { get ; set ; }
112+ /// <summary>
113+ /// Gets or sets the name of the person.
114+ /// </summary>
63115 public string Name { get ; set ; } = string . Empty ;
116+ /// <summary>
117+ /// Gets or sets the age of the person.
118+ /// </summary>
64119 public int Age { get ; set ; }
120+ /// <summary>
121+ /// Gets or sets the email address of the person.
122+ /// </summary>
65123 public string Email { get ; set ; } = string . Empty ;
124+ /// <summary>
125+ /// Gets or sets the department of the person.
126+ /// </summary>
66127 public string Department { get ; set ; } = string . Empty ;
67128}
0 commit comments