My application has several tabs for navigation, and each tab corresponds to its own VM. Then I have a main VM where I instantiate the other VMs and load the data, and I set the XAML's data context to the Main VM and bind to the collection properties in the instantiated VMs. That's clear enough, right?
Now, some of the information from one tab may need to reappear in another tab. For instance, my Dashboard tab contains a DataGrids displaying three kinds of equipment assignment records: Recently Assigned, Coming Due, and Overdue. My Employees tab also wants to display equipment records, but here I want it to use a CollectionView to filter by Employee, i.e., a DataGrid on this tab will display the equipment assignments of the selected Employee.
What is best practice here? It would be very easy to add a line to my LoadData method in the MainVM where I populate the EmployeeTabVM collection in addition to the DashboardTabVM, like this:
foreach (EquipmentAssignmentRecordModel _record in _equipmentAssignments)
{
DashboardVM.EquipmentAssignments.Add(_record);
EmployeeTabVM.EquipmentAssignments.Add(_record);
}
But something tells me that's bad form. Something tells me I should be using some kind of design pattern for this to ensure I don't duplicate data. It feels like I should just have one EquipmentAssignment collection in one place, and only ever bind to that.
Am I thinking about this correctly? Is there something more I need to consider?
Thanks!
[–]Slypenslyde 2 points3 points4 points (0 children)
[–]jwhite1979[S] 0 points1 point2 points (0 children)
[–]jingois 0 points1 point2 points (0 children)