Пример #1
0
        private void Filter_Checked(object sender, RoutedEventArgs e)
        {
            Listbox.ItemsSource = null;
            List <Library> filteredItems = new List <Library>();

            if (BookFilter.IsChecked == true)
            {
                filteredItems.AddRange(libraryRepository.GetAllBooks());
            }
            else
            {
                foreach (Library item in libraryRepository.GetAllBooks())
                {
                    filteredItems.Remove(item);
                }
            }

            if (CDFilter.IsChecked == true)
            {
                filteredItems.AddRange(libraryRepository.GetAllCds());
            }
            else
            {
                foreach (Library item in libraryRepository.GetAllCds())
                {
                    filteredItems.Remove(item);
                }
            }

            if (DVDFilter.IsChecked == true)
            {
                filteredItems.AddRange(libraryRepository.GetAllDvds());
            }
            else
            {
                foreach (Library item in libraryRepository.GetAllDvds())
                {
                    filteredItems.Remove(item);
                }
            }
            if (CDFilter.IsChecked == false && DVDFilter.IsChecked == false && BookFilter.IsChecked == false)
            {
                filteredItems = libraryRepository.GetAllLibraryItems();
            }

            Listbox.ItemsSource = filteredItems;
        }
 private void ShowCDsInListbox()
 {
     CatalogusListbox.ItemsSource = null;
     CatalogusListbox.ItemsSource = libraryRepository.GetAllCds();
 }