Hi I have an ObservableCollection<Setting>
where Setting
is described below
public class Setting
{
public string Name { get; set; }
public string Group { get; set; }
public string SubGroup { get; set; }
public override string ToString()
{
return Name;
}
}
I want to have two listboxes where the first one contains contains only the list of groups (Group property) while preserving ability to select any group (and launch consequent filtering of settings in the second listbox by selected group of the first one)and the second one contains the full collection of settings grouped by SubGroup property . I'm going to wrap my list of settings into two different CollectionViewSource
for ItemsSource
properties of listboxes but in case of the first listbox I can't select any group because it is not actually an element of underlying collection. How can I implement it? I still have to maintain filtered state of groups in the first list box. Sample view is on attached image.
Before filtering
After filtering
I managed to fix it by having property called SettingGroups
in my view-model of ICollectionView
which I get from my observable collection property. I added group description and bound first list box to SettingGroups.Groups
. Now filtering of underlying collection view works fine so only groups having at least one filtered in setting are displayed in the first listbox