I have an app in WPF without MVVM, I decided to refactor this to MVVM. I encountered a problem with a ComboBox SelectionChanged event. Basically to make it simpler lets assume i Have one ComboBox and 2 ListView's. Every ComboBoxItem is a collection. First ListView's ItemsSource is bound to the collection from the ComboBox.SelectedValue but only to the part whose one property(of decimal) is greater than zero. Second ListView's ItemsSource is bound to the same colection but to the second part(some prop greater than zero). Below some code to understand
private void myCombo_selectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox myCmb = sender as ComboBox;
List<myType> myList = myCmb.SelectedValue as List<myType>;
itemsForListView1 = myList.Where((x) => x.myProp > 0);
itemsForListView2 = myList.Where((x) => x.myProp < 0);
// Above 2 collections are of Type List<myType> and their scope will be whole ViewModel,
//so i assume i just need to change them and RaisePropChanged but how to change them without breaking mvvm ?
MyListView1.ItemsSource = itemsForListView1;
MyListView2.ItemsSource = itemsForListView2;
}
How can I achieve something similiar in MVVM ?