Hi,
We are using MVVM model. There are two grids parent and Child. Child Grid will be loaded on selecting any Parent row. Child grid will have all cells in Edit mode on Cell Focus and any change done to the cells will be auto saved. The task is to reload the Parent and Child grid when any concurrency exception occurs while auto saving Cells in Child grid. Below code is used to raise an Concurrency exception in viewmodel which is handled to display message box. Once the message is shown dispatcher exception is occuring.
Can you suggest any solution to avoid the Dispatcher exception?
Xaml.cs
---------
private void childgrd_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
viewmodel.HandleCellEditEnded(e.Cell.Column.DisplayIndex);
viewmodel.HeaderSelected = e.Cell.Column.Header.ToString();
}
viewmodel
-------------
public void HandleCellEditEnded(int Column)
{
Update();
}
public void Update()
{
try
{
//Save child grid changes
}
catch (DbUpdateConcurrencyException)
{
MessageBox.Show("Concurrency exception occured");
SelectedParent = null;
ParentGridCollection = null;
SelectedChild = null;
childGridCollection = null;
LoadParent();
}
}
Regards,
Vinetha.P