HI All,
Hope someone can assist me. I have a XAMDataGrid and a Combobox on my form. The combobox has 2 items. What i want to do is set the following fields:
Combo Index 0 Selected:
1. FieldSettings - CellClickAction: EnterEditModeIfAllowed
2. FieldLayoutSettings - SelectionTypeCell: Single
Combo Index 1 Selected:
1. FieldSettings - CellClickAction: SelectCell
2. FieldLayoutSettings - SelectionTypeCell: ExtendedAutoDrag
When I set the value in code behind I get the following error: "Exception has been thrown by the target of an invocation."
FieldSettings set = testGrid.FieldSettings; FieldLayoutSettings lay = testGrid.FieldLayoutSettings;
if (matrixTuningComboBox.SelectedIndex == 1) { set.CellClickAction = CellClickAction.SelectCell; lay.SelectionTypeCell = Infragistics.Windows.Controls.SelectionType.ExtendedAutoDrag; } else { set.CellClickAction = CellClickAction.EnterEditModeIfAllowed; lay.SelectionTypeCell = Infragistics.Windows.Controls.SelectionType.Single; }
testGrid.FieldSettings = set; testGrid.FieldLayoutSettings = lay;
Please see the attachment.
Sample.zip
Friendly Regards,
Roelof
Hello Roelof,
I apologize for the delay in my response. It appears that the issue in this case was related to a timing issue in which in your RowStyleConverter, the elements at values[0] and value[1] will be "DependencyProperty.UnsetValue" for a short time. This happens when setting the FieldSettings and FieldLayoutSettings of the XamDataGrid when the SelectionTypeCell is "single," although at the moment, I'm not entirely sure as to why. I'm also unsure why the Visual Studio debugger didn't seem to be failing in the converter, as this would've made this issue much easier to detect.
In order to work around this issue, I would recommend checking values[0] and values[1] for the "int" type prior to casting them to ints. This appears to resolve the erroneous behavior you are seeing.
Please let me know if you have any other questions or concerns on this matter.
HI Andrew,
Thanks for the reply. Waiting for your investigation result.
I have been investigating into your sample project on this matter, and have reproduced the behavior you are seeing. After investigating the actual exception that is occurring, nothing in the stack trace appears to be Infragistics-related, but I cannot seem to see a problem with the code that you have provided in the sample either.
Interestingly, if I comment out the code that is checking the e.PropertyName for "ColIndex" I cannot seem to get this exception to happen, which leads me to believe that this is a timing issue with the application you sent versus the internal code of the XamDataGrid.
I will be continuing to investigate into this behavior and I hope to have more information for you soon. Please let me know if you have any other questions or concerns on this matter.