i'm facing the following issue
in my (C#/WPF) application illustration
i build an itemsControl that display a collection of UserControl which themselves contain, among other, a dataGrid. i'm using the following code structure:
// define the content of ItemsControl
public class ICContent
{
public BindingList<bool> AllRowsVisibility { get; set; }
public BindingList<UCContent> UCContentList { get; set; }
}
// define the content of 1 UserControl
public class UCContent
{
public string GeneralStuff { get; set; }
public BindingList<AllRowsDetails> RowDetails { get; set; }
}
// define all the datagrid rows for each UserControl
public class AllRowsDetails
{
// IsRowVisible is use in the dataBinding to collapse/display the row
public bool IsRowVisible { get; set; }
public string ColumnA { get; set; }
public string ColumnB { get; set; }
}
all the dataGrid rows must be able to be filtered. to do that i use AllRowsDetails.IsRowVisible to trigger the collapse/visible property for each rows.
the problem is that if i set AllRowsDetails.IsRowVisible for each rows of each UserControl datagrid, the calculation take too much time.
So, i calculate ICContent.AllRowsVisibility one time, and i want the ICContent.AllRowsVisibility elements and AllRowsDetails.IsRowVisible elements share the same reference.
in this way: UCContentList[i].rowDetails[j].IsRowVisible = AllRowsVisibility[j]
and every time AllRowsVisibility[j] change, UCContentList[i].RowDetails[j].IsRowVisible change too
but i don't know how different elements can share the same ref?
I set up the @Fabio solution:
i build the class that describe my ItemsControl
i instanciate two ICContent objects
And in my codeBehind i add a new event handler to the changing selected filter event:
it works well, and it's pretty fast.
Thanks @Fabio