## Поиск, сортировка
XAML:
```
...
...
```
C#:
```
...
public IEnumerable ProductList
{
get
{
var res = _productList;
res = _productList
.Where(p =>(selectedCategory == "Все категории" || p.Category == selectedCategory))
.Where(p =>(selectedPrice == null || (p.Price>=selectedPrice.priceFrom && p.Price(selectedCompany == "Все компании" || p.Company == selectedCompany));
if (searchFilter != "")
res = res.Where(c => c.Title.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0);
if (sortAsc) res = res.OrderBy(p => p.Price);
else res = res.OrderByDescending(p => p.Price);
return res;
}
set
{
_productList = value;
}
}
...
```
```
...
private string searchFilter = "";
private bool sortAsc = true;
private void SearchFilterTextBox_KeyUp(object sender, KeyEventArgs e)
{
searchFilter = SearchFilterTextBox.Text;
Invalidate();
}
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
sortAsc = (sender as RadioButton).Tag.ToString() == "1";
Invalidate();
}
...
```
Результат:
![](./img/result1.png)
![](./img/result2.png)