public void PopulateInvoices() { foreach (DataInvoice inv in InvoiceHelper.GetAllInvoices()) { Invoices.Add(inv); } UniqueCompanies.Clear(); FilterBox.Items.Clear(); List <string> companyNames = new List <string>(); foreach (DataInvoice invoice in Invoices) { if (!companyNames.Contains(invoice.CompanyName)) { companyNames.Add(invoice.CompanyName); UniqueCompanies.Add(invoice); CheckBox checkBox = new CheckBox() { DataContext = invoice, Content = invoice.CompanyName }; checkBox.Checked += CheckBox_Checked; checkBox.Unchecked += CheckBox_Checked; FilterBox.Items.Add(checkBox); } } }
void PopulateInvoices() { CompanyInvoices = new ObservableCollection <DataInvoice>(); if (DataContext == null) { return; } foreach (DataInvoice inv in InvoiceHelper.GetAllInvoices()) { if (((DataCompany)DataContext).CompanyName == null) { return; } if (inv.CompanyName == ((DataCompany)DataContext).CompanyName) { CompanyInvoices.Add(inv); } } ListViewInvoices.ItemsSource = CompanyInvoices; CollectionViewSource.GetDefaultView(ListViewInvoices.ItemsSource).Refresh(); }