I have a MVVM implementation, where the ViewModel is an Entity Framework set (colleciton) bound to a grid. This works fine..until an addition happens.
The add is from a form (Not in grid) , and is persisted to the store correctly.
In my code, I do the following:
- Set the dg.ItemsSource = null;
- Recreate the viewModel ( this.Model = new MyModel(); )
- set the dg.ItemsSource = this.Model ;
- Iterate the Model entities - all are there (Debug.WriteLine(item.Name);)
- bind the grid with this.dg.Items.Refresh();
The grid does not show the new item :( If I restart the app, the item appears.
Any idea what I am missing here ?