Hello,
I have a content presenter, which using a templateSelector decides if i want to show a XamGrid or another control.
My XamGrid has validation, when i want to add a row with not valid data, and than trying to change the DataContext and the ItemsSource of the XamGriw (without exiting adding new row), i get the following exception:
{"Exception has been thrown by the target of an invocation."}
with stacktrace:
at Infragistics.Controls.Grids.XamGrid.ExitCellFromEditModeInternalRow(Boolean cancel) at Infragistics.Controls.Grids.XamGrid.ExitEditModeInternal(Boolean cancel) at Infragistics.Controls.Grids.XamGrid.ExitEditMode(Boolean cancel) at Infragistics.Controls.Grids.RowsManager.InvalidateFiltering() at Infragistics.Controls.Grids.RowsManager.InvalidateData() at Infragistics.Controls.Grids.RowsManager.OnItemsSourceChanged(Boolean invalidateSelectionAndActivation) at Infragistics.Controls.Grids.RowsManager.set_ItemsSource(IEnumerable value) at Infragistics.Controls.Grids.XamGrid.ApplyItemSource(IEnumerable itemSource) at Infragistics.Controls.Grids.XamGrid.ItemsSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
Can you help me how to solve this problem?
Hello Michael,
I have been reading through your description and am not quite sure what might be causing this issue, so I was wondering if you have tried this without the TemplateSelector and if you have a project I can look at that reproduces this?
Looking forward to hearing from you.
Hi,
It is very hard to isolate this from my project to send you.
Anyway, This exception happens only when a cell has validation error , and than when i am changing the DataContext and the ItemsSource of the XamGrid, This exception is thrown.
When there is no cell validation error, and i am still changing the DataContext and ItemsSource, everything works fine.
So i don't think it is related to the TemplateSelector
It seems that the XamGrid doesnt ExitEditRow after cell validation error. So i need to do it manually, which i think is wrong. Anyway, i think it is XamGRid bug
I am still following your case. I am just checking the progress of this and if you need any more assistance.
Excuse me for the late reply, I have been looking into your issue and if you are changing your ItemsSource whilst in edit mode, it is expected to get a n exception, since the data you are using suddenly disappears. It is the suggested way to exit edit mode manually, when you change your data. This is not done out of the box, because there is no way to figure out and handle all possible ways for changing your data. Also e.g. listening for the DataContextChanged event in order to exit edit mode internally is not possible since no everyone uses their DataContext to bind their data only. To sum up, the XamGrid is not meant to anticipate that you would change your data while you are editing it.
Please let me know if I can provide you with any further clarification on the matter.