question

ApptacularApps-8305 avatar image
0 Votes"
ApptacularApps-8305 asked ·

How to use 'or' statemnt in return function

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);

windows-uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

danielescipioni avatar image
0 Votes"
danielescipioni answered ·

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); });
}
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.