Skip to content

Commit 47208a0

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/windows-dev-docs-pr (branch live)
2 parents 7d2c08d + 3ab4c05 commit 47208a0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hub/apps/design/controls/listview-filtering.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Filter the items in your collection through user input.
33
title: Filtering collections
44
label: Filtering collections
55
template: detail.hbs
6-
ms.date: 12/3/2019
6+
ms.date: 3/20/2024
77
ms.topic: article
88
keywords: windows 10, uwp
99
pm-contact: anawish
@@ -76,14 +76,17 @@ The code below performs the filtering operation through the following steps, sho
7676
```csharp
7777
using System.Linq;
7878

79+
IList<Person> People;
80+
ObservableCollection<Person> PeopleFiltered;
81+
7982
public MainPage()
8083
{
8184
// Define People collection to hold all Person objects.
8285
// Populate collection - i.e. add Person objects (not shown)
83-
IList<Person> People = new List<Person>();
86+
People = new List<Person>();
8487

8588
// Create PeopleFiltered collection and copy data from original People collection
86-
ObservableCollection<Person> PeopleFiltered = new ObservableCollection<Person>(People);
89+
PeopleFiltered = new ObservableCollection<Person>(People);
8790

8891
// Set the ListView's ItemsSource property to the PeopleFiltered collection
8992
FilteredListView.ItemsSource = PeopleFiltered;
@@ -99,7 +102,7 @@ private void FilteredLV_LNameChanged(object sender, TextChangedEventArgs e)
99102

100103
/* Make sure all text is case-insensitive when comparing, and make sure
101104
the filtered items are in a List object */
102-
TempFiltered = people.Where(contact => contact.LastName.Contains(FilterByLName.Text, StringComparison.InvariantCultureIgnoreCase)).ToList();
105+
TempFiltered = People.Where(contact => contact.LastName.Contains(FilterByLName.Text, StringComparison.InvariantCultureIgnoreCase)).ToList();
103106

104107
/* Go through TempFiltered and compare it with the current PeopleFiltered collection,
105108
adding and subtracting items as necessary: */

0 commit comments

Comments
 (0)