I have a XamDataGrid that is bound to a dataset with multiple parent-child tables. This particular dataset has Expression fields in nearly every table that perform counting and sums. Each row acts as a toggle switch that turns an artificial selection flag on / off . When clicking on a row very quickly, the row's parent sometimes collapses for no apparent reason. Sometimes another unrelated parent collapses for no apparent reason. I am trying to better understand why this would happen but the first trick is to catch the send of the collapse in the act... So, how do I detect a row collapse?
Hello,
RecordCollapsing/ed would be probably the event you are looking for. Have you tried handling that?
How do you "toggle" the switch record -with MouseLeftButtonDown event? Is this flag a property of the underlying data object?
Hi Alex,
I haven't tried that one (and I will). I toggle the record with a left mouse click and the selection state is in fact set in the underlying dataset (as you correctly surmised).
Thanks.
I am not sure how clicking on a record would collapse its parent or another record, but I would like to see that and it's really strange. You can try the PreviewMouseLeftButtonDown for record clicking and cancel of RecordCollapsing if it does get fired.
What comes in my mind is that, if you accidentally click on the label, records can get sorted and change positions - this can be observed when they are grouped.
I wasn't able to find an exact cause but I did find a workaround... which is to eliminate all DataSet Field Expressions that reference child tables. Once these are gone the problem stops occuring.
It get's even more interesting. I hooked up the RecordCollapsed event and when the unexpected collapse occurs, the event doesn't get triggered. As a control test, I manually collapsed some branches and the event triggered as expected.