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
editor.Document.CaretPosition.MoveToPreviousInline();
var currpara = editor.Document.CaretPosition.GetCurrentParagraphBox().AssociatedParagraph;
var atable=ExpandedColl.Where(x=>x.Key==spanbox.Tag).FirstOrDefault().Value;
if
(atable!=
null
)
{
currsect.Blocks.AddAfter(currpara, atable);
}
<telerik:RadNumericUpDown Margin="0, 4, 0, 4" Value="{Binding MyValue, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Maximum="{Binding MaxWidthValue}" IsEnabled="{Binding IsPropertyEnabled}"/> MyValue is changed from data.
The problem is :
If this RadNumericUpDown has focus, the UI value does not change even though MyValue changed in Data. As soon as Tab out from this control, UI will change immediately.
If this control does not have focus, the UI displayed value will change instantly as MyValue changes.