using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using WpfApp1.Entities; namespace WpfApp1 { /// /// Логика взаимодействия для TaskPage.xaml /// public partial class TaskPage : Page { public TaskPage() { InitializeComponent(); LViewTasks.ItemsSource = user20Entities.GetContext().Task.ToList(); var allTypes = user20Entities.GetContext().Task.ToList(); allTypes.Insert(0, new WpfApp1.Entities.Task { Title = "Все типы" }); ComboType.ItemsSource = allTypes; CheckDeleted.IsChecked = true; ComboType.SelectedIndex = 0; } private void TBoxSearch_TextChanged(object sender, TextChangedEventArgs e) { UpdateTasks(); } private void UpdateTasks() { var searchText = TBoxSearch.Text.ToLower(); var Tasks = user20Entities.GetContext().Task.ToList(); var currentTasks = user20Entities.GetContext().Task.ToList(); if (ComboType.SelectedIndex > 0) currentTasks = currentTasks.Where(p => p.WorkType == ComboType.SelectedItem).ToList(); currentTasks = currentTasks.Where(p => p.Title.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList(); if (CheckDeleted.IsChecked.Value) currentTasks = currentTasks.Where(p => p.IsDeleted).ToList(); } private void CheckDeleted_Checked(object sender, RoutedEventArgs e) { UpdateTasks(); } private void ComboType_SelectionChanged(object sender, SelectionChangedEventArgs e) { UpdateTasks(); } } }