Developer technologies | Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows devices.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How can I use more than 1 item properties when filtering a list view? In my return statement I also want to use the family of my flower alongside the name of it i.e.
private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)
{
if (string.IsNullOrEmpty(txtSearch.Text))
{
this.ListFlowers.ItemsSource = this.listItemFlowers;
}
this.ListFlowers.ItemsSource = this.listItemFlowers.Where((item) => { return item.FlowerName.Contains(txtSearch.Text, StringComparison.InvariantCultureIgnoreCase); });
}
I also want to include something like:
return item.FlowerFamily.Contains(txtSearch.Text, StringComparison.InvariantCultureIgnoreCase);
A Microsoft platform for building and publishing apps for Windows devices.
Answer accepted by question author
Use the or operator ||
private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)
{
if (string.IsNullOrEmpty(txtSearch.Text))
{
this.ListFlowers.ItemsSource = this.listItemFlowers;
}
this.ListFlowers.ItemsSource = this.listItemFlowers.Where((item) => { return item.FlowerName.Contains(txtSearch.Text, StringComparison.InvariantCultureIgnoreCase) || item.FlowerFamily.Contains(txtSearch.Text, StringComparison.InvariantCultureIgnoreCase); });
}