Task:
I want to hide a part of my CSLA ChildList but without using any extra Columns in my Database. (like visible ? true / false)
Example: I have a List of all member. Im setting a filter which allows me to see only the member with the number 3. Now I can edit the filterd List. After removing the filter I can see the whole List again and the edited Members without saving between the actions.
Im ending up in having two Lists. One is the filtert and one of all Members. Maybe there are some commands I don't know?
Code:
private int _selectedGroup;
public int SelectedGroup
{
get
{
return _selectedGroup;
}
set
{
if (_selectedGroup!= value)
{
_selectedGroup= value;
OnPropertyChanged(() => SelectedGroup);
FilterByGroup();
}
}
}
Calling the Filter Method after changing the numner to filter.
private void FilterByProduktgrp()
{
// List All
List = Model.ChildList;
//Filtered List
List = List.Where(c => c.ID == FilterID);
}
Now I need to get the edited List into the Model.ChildList
As Mark says, there are many ways to achieve your goal. Judging by your code so far, you seem to be approaching this problem from the same way that I would. That way is this... basically, you need one private collection property that will always hold the complete collection of items. Then you need another public collection property that is data bound to some UI container control.
Upon initialisation of your view model, fetch the data and fill up your private collection. This will be used to populate your data bound collection dependant upon whatever filter properties that you choose. You can even build this filtering process into the filter property setter if you prefer: