Perhaps I'm overthinking this? I'm trying to find a way to use the classic WPF filter logic, and I'm adding onto it to hide/show any items that contain the errors that are checked/unchecked.
private void viewSource_Filter(object sender, FilterEventArgs e)
{
var typeCheck = e.Item.GetType().ToString();
if (e.Item.GetType().ToString() == "Client_Invoice_Auditor.CoreClientAR.dailyAccountBalance")
{
dailyAccountBalance DAB = (dailyAccountBalance)e.Item;
int count = errorFilters.Where(w => w.IsChecked).Count(w => DAB.Errors.Contains(w.Item));
if (count == 0)
{
DAB.Visibility = "Collapsed";
var toHideDAB = DABView.Items.GetItemAt(DAB.RowIndex);
TreeViewItem hideItemDAB = DABView.ItemContainerGenerator.ContainerFromItem(toHideDAB)
as TreeViewItem;
if(hideItemDAB != null)
hideItemDAB.Visibility = Visibility.Collapsed;
e.Accepted = false;
return;
}
DAB.Visibility = "Visible";
var toShowDAB = DABView.Items.GetItemAt(DAB.RowIndex);
TreeViewItem showItemDAB = DABView.ItemContainerGenerator.ContainerFromItem(toShowDAB)
as TreeViewItem;
if(showItemDAB != null)
showItemDAB.Visibility = Visibility.Visible;
e.Accepted = true;
}
}
Right now, this code doesn't work perfectly - only some of the qualifying items will disappear, only to never re-appear again.
I can give more code if needed. Can anyone provide alternate suggestions? I know I have the concept of showing/hiding the treeview item down, it's just a matter of matching the filter...
Comments
Post a Comment