Hi
I have a datatemplate with Expander control containing XamPivotGrid inside the PivotCell of the XamDatagrid.
Our requirement was to show two different types of controls in the XamPivotGrid PivotCells which I have implemented using the OnCellControlAttached event.
Now when scrolling is done for the XamPivotGrid, this OnCellControlAttached event again is raised may be due to virtualization.
Due to this raised event, the expander control is collapsed and the selected row in the xamdatagrid which is present in the PivotCell is lost.
What I need is that if there is any way by which the OnCellControlAttached event not to get raised for the already loaded PivotCells (may be to stop the virtualization for already loaded cells). This way my functionality of selections in the PivotCell would not get lost.
If anyone has understood above please help with a sample.
Thanks, Rakesh Bisht
Hello Rakesh,
Let me know if you have any further questions on this matter.
I've taken your sample and modified it so that it persists the selected rows of the grids. I added a Dictionary and associated a collection of integers with a PivotCell that contains the XamDataGrid. The integers are the indices of the selected records so that I can reselect them when a new instance of the XamDataGrid is created.
Let me know if you have any questions.
Hi Rakesh,
The reason the selection is lost is because the selection information is not stored anywhere to be restored later. When the grid is scrolled and PivotCellControl instances are replaced, it also replaces the XamDataGrid within the cell control so all the selection information is lost. I have an idea for a workaround that I am trying which involves associating the actual PivotCell behind the PivotCellControl with the selection information of the XamDataGrid. That way, when a different instance of the grid is used for that cell, I can restore the selection data. I will keep you updated on how it turns out.
Hello Rob,
Thanks for your reply.
I have modified one of the samples with implementing my current requirement(control template) and attached the same.
In the sample if you click and expand any of the expander control, a xamdatagrid is displayed with sample data.
And now if you click any of the record in the XamDatagrid you have some selection set by User.
At this moment if User scrolls the XamPivotGrid and the previously selected PivotCell goes out of view, then the selection of the child xamdatagrid is lost.
Request you to please suggest any workaround if any.
Thanks Rakesh
You are right about the OnCellControlAttached event, in that it will fire multiple times due to virtualization. As new cells are scrolled into view, they have controls attached to them. This is when the event is fired. The only way to stop this event would be to disable virtualization on the XamPivotGrid, and I'm pretty sure that it can't be turned off, nor would you want it off as it could introduce major performance issues.
Can you provide me with the DataTemplate you are using, and the code you have in OnCellControlAttached? So I can build a sample using it to replicate your issue.