Hello,
Here is my issue :
I have a grid with a group by default and i click on an item to select it :
When I remove the group the activecell is set to the first element of the list but the row underlying stay the good :
I didn't find the way to keep the good row active. The thing is that when i do the reverse, no group by default, a row selected :
And i apply a group, the row is still selected and active :
Is that a normal behavior ? And how can i keep the good row active in the first case ?
I post the solution.
Regards.
Fabien.
Hi,
I was on holidays last week so i just saw your reply. Thanks for the solution it works perfectly.
Fabien
Hi Fabien,
Let me know if you have any questions on this.
Looking at the sample I can't see why a NullReferenceException is being thrown on assigning the ActiveCell a valid cell. I do however have a suggestion that may resolve your initial problem. It's a slightly hack'ish way of doing it but it should work for your original sample. The work around assumes that the ActiveCell should never be null. I can't think of any reasons why it would ever need to be null but if you rely on ActiveCell being null for anything then this method might not work for you.
You can hook into the ActiveCellChanging event and use the event arguments to check what the ActiveCell will be changed to. If this new cell is null then you can just cancel the event and the ActiveCell will remain at it's current location. This works because when you remove a grouping the XamGrid assigns the ActiveCell to null. When the ActiveCell is null the XamGrid automatically "selects" the first cell in the grid which is what you were seeing originally.
I have attached an updated sample using this method.
Thanks for the solution it works but I found a bug when more than one group is applied.
When I ungroup the last group applied everything's fine :
But when I ungroup one of the previous groups an exception occured with the message :
"A first chance exception of type 'System.NullReferenceException' occurred in InfragisticsSL4.Controls.Grids.XamGrid.v11.1"
Best Regards.
You could add an event handler to GroupByCollectionChanged event and set the active cell on the desired row. I modified your sample to demonstrate how to do that. You can find it attached.
Hope this helps,