I need help. I am kind of new in MVVM I've got event datagrid selecteditem event in MVVM. After creating a source for grid items(void search) I need populate combobox source as a filter values based on main collection. I used(before MVVM) to work with event subscribing, but can not achieve it here. If I put OnPropertChanged("FamilyFilter") at the end of main function combobox selectionchanged event start working immediately. Here is the code:
public IList<Object> somelist { get; set; }
public CollectionView Items { get; set; }
private string _selectedFamily;
public string SelectedFamily
{ get { return _selectedFamily; }
set { Items = <<filteredcollection>>; OnPropertyChanged("SelectedFamily"); }
}
private List<string> _familyEntries;
public List<string> FamilyEntries
{ get { return _familyEntries; }
set { _familyEntries = value; OnPropertyChanged("FamilyEntries");}
}
public void search()
{
Items = (CollectionView)CollectionViewSource.GetDefaultView(somelist);
_familyEntries = somelist.GroupBy(x => x.Family).Select(z => z.First().Family).ToList();
OnPropertyChanged("Items");
OnPropertyChanged("FamilyEntries");
}
<ComboBox ItemsSource="{Binding FamilyEntries}" SelectedValue="{Binding SelectedFamily}"/>